fix: fpm run: improve error message#1303
Open
perazz wants to merge 2 commits into
Open
Conversation
… line"
When a compiler, wrapper, or archiver executable is missing, a build failed
with the misleading runtime message "Invalid command line" (libgfortran's text
for a shell exit 126/127), which looks like a bad compiler flag rather than a
missing program.
`run` now detects a failed launch on both Unix (cmdstat/=0) and Windows
(cmdstat==0 but cmd.exe exit 9009), and when the invoked program cannot be
found on PATH reports:
Could not execute '<name>': program not found on PATH.
Check that it is installed and on your PATH, or set it explicitly with
--compiler / FPM_FC (use FPM_CC / FPM_AR for the C compiler / archiver).
Detection is by name via the existing cross-platform which()/exists(), using
fpm's own shell lexer (fortran-shlex) to extract the program token, so quoted
paths and compiler wrappers (mpifort, caf, ...) resolve correctly. The check
runs only after a command has already failed, so the success path is unaffected.
Adds command_program/command_not_found helpers and unit tests pinning the
program extraction against the real command shapes fpm emits.
e37512d to
9fd005b
Compare
fpm run: improve error message
The Windows lexer (ms_split) reports success=.false. when a command contains
redirection metacharacters (">", "2>&1"), even though it still tokenizes the
command correctly. command_program only used the tokens when success was true,
so it returned an empty program name for commands with inline redirects (e.g.
the "<cc> --version > out 2>&1" and "mpifort -show > out 2>&1" probes), which
broke the standard-command test on Windows.
Rely on the first token instead of the success flag: a redirection operator
never starts a command, so the first token is reliably the program. This also
makes the missing-program message work for the inline-redirect probe commands
on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cf. https://fortran-lang.discourse.group/t/fpm-failing-at-the-first-hurdle/10968/5