Skip to content

Improve diagnostics when command execution fails in run()#1263

Open
ZainabTravadi wants to merge 1 commit intofortran-lang:mainfrom
ZainabTravadi:improve-run-error-diagnostics
Open

Improve diagnostics when command execution fails in run()#1263
ZainabTravadi wants to merge 1 commit intofortran-lang:mainfrom
ZainabTravadi:improve-run-error-diagnostics

Conversation

@ZainabTravadi
Copy link
Copy Markdown
Contributor

Summary
Improve diagnostics when commands executed via run fail.

Changes

  • Print an error message when a command returns a non-zero exit status and exitstat is not present
  • Preserve existing API behavior and control flow
  • Print diagnostics to stderr for consistency

This prevents silent command failures and improves debugging during builds.

Fixes #1262

Copilot AI review requested due to automatic review settings March 13, 2026 13:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates library directory collection and error reporting to improve runtime/library-path handling and build/run diagnostics in the Fortran Package Manager codebase.

Changes:

  • Adjust get_library_dirs filtering/behavior when collecting library output directories.
  • Add stderr logging in run() when a command fails and the caller didn’t request exitstat.
  • Tweak build failure messages in the backend.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/fpm_targets.f90 Changes which target types contribute to collected library directories (used for -L flags and runtime path setup).
src/fpm_filesystem.F90 Adds an extra error print on failed execute_command_line calls when exitstat is not provided.
src/fpm_backend.F90 Minor wording/capitalization changes to compilation-failure messaging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fpm_targets.f90 Outdated
Comment on lines +1386 to +1389
! Only consider shared library targets (.so) since
! only they require runtime lookup via LD_LIBRARY_PATH.
if (.not. any(target%target_type == [FPM_TARGET_SHARED])) cycle
! Always include the output_dir for shared libraries
Comment thread src/fpm_targets.f90 Outdated
Comment on lines +1386 to +1388
! Only consider shared library targets (.so) since
! only they require runtime lookup via LD_LIBRARY_PATH.
if (.not. any(target%target_type == [FPM_TARGET_SHARED])) cycle
Comment thread src/fpm_filesystem.F90
Comment on lines +1055 to +1058
if (.not. present(exitstat) .and. stat /= 0) then
write(stderr,'(a,i0)') '<ERROR>: command '//cmd//redirect_str//' returned status code ', stat
end if

@ZainabTravadi ZainabTravadi force-pushed the improve-run-error-diagnostics branch from d7f8be4 to 3a5b077 Compare March 13, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve diagnostics when command execution fails in run

2 participants