Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfortran: command not found on macos-latest #3371

Closed
1 of 7 tasks
paulmueller opened this issue May 12, 2021 · 12 comments
Closed
1 of 7 tasks

gfortran: command not found on macos-latest #3371

paulmueller opened this issue May 12, 2021 · 12 comments
Assignees
Labels
Area: Apple OS: macOS question Further information is requested

Comments

@paulmueller
Copy link

Description

The command "gfortran" is not available in the latest macOS builds. Calling gfortran --version fails with the following error on macos-latest:

/Users/runner/work/_temp/b20baed3-9e90-42e3-a7d3-dcacff880807.sh: line 2: gfortran: command not found
Error: Process completed with exit code 127.

Area for Triage: Apple

Question, Bug, or Feature?: Bug

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15.7 (macos-latest)
  • macOS 11.0
  • Windows Server 2016 R2
  • Windows Server 2019

Image version: 20210503.2

Image version where you are experiencing the issue.

Expected behavior
gfortran --version should print the version of gfortran

Actual behavior
command not found

Repro steps
CI job:
https://github.com/ZELLMECHANIK-DRESDEN/dclab/runs/2567423623?check_suite_focus=true

relevant line in yml:
https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/master/.github/workflows/check.yml#L27

@github-actions github-actions bot added Area: Apple investigate Collect additional information, like space on disk, other tool incompatibilities etc. labels May 12, 2021
@miketimofeev
Copy link
Contributor

Hi @paulmueller!
You need to specify gfortran major version as it is described in the docs:
image
We don't have the gfortran alias intentionally, please take a look at this comment:
#1280 (comment)

@miketimofeev miketimofeev added OS: macOS question Further information is requested and removed investigate Collect additional information, like space on disk, other tool incompatibilities etc. needs triage labels May 12, 2021
@miketimofeev miketimofeev self-assigned this May 12, 2021
@paulmueller
Copy link
Author

The problem is that I intend to install the R package statmodel which somehow needs gfortran to build. I am not in control. Is there a way to manually add a global alias gfortran -> gfortran-8?

paulmueller added a commit to DC-analysis/dclab that referenced this issue May 12, 2021
@paulmueller
Copy link
Author

I manually added the symlink ln -s /usr/local/bin/gfortran-10 /usr/local/bin/gfortran (found it in the thread you mentioned). Will close this issue if it works.

@paulmueller
Copy link
Author

The yaml entry I used:

    - name: symlink gfortran (macOS)
      if: runner.os == 'macOS'
      run: |
        # make sure gfortran is available
        ln -s /usr/local/bin/gfortran-10 /usr/local/bin/gfortran
        gfortran --version

@paulmueller
Copy link
Author

paulmueller commented May 12, 2021

Sorry, I have to reopen. Building the statmodel package fails. Could you please help me with this thing:

https://github.com/ZELLMECHANIK-DRESDEN/dclab/runs/2568138465?check_suite_focus=true

----------------------------- Captured stdout call -----------------------------
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c gaussq2.f -o gaussq2.o
clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c init.c -o init.o
clang -mmacosx-version-min=10.13 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o statmod.so gaussq2.o init.o -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
----------------------------- Captured stderr call -----------------------------
* installing *source* package ‘statmod’ ...
** package ‘statmod’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [statmod.so] Error 1
ERROR: compilation failed for package ‘statmod’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/statmod’

Do I also have to update a library path or so? I don't know how things work on macOS.

@paulmueller paulmueller reopened this May 12, 2021
@miketimofeev
Copy link
Contributor

@paulmueller could you please file another issue and provide all the details there?

@miketimofeev
Copy link
Contributor

@paulmueller looks like we already had pretty the same issue. Could you take a look here, please?
#2524

@paulmueller
Copy link
Author

Thanks for your help, that worked:

    - name: Symlink gfortran (macOS)
      if: runner.os == 'macOS'
      run: |
        # make sure gfortran is available
        # https://github.com/actions/virtual-environments/issues/2524
        # https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
        sudo ln -s /usr/local/bin/gfortran-10 /usr/local/bin/gfortran
        sudo mkdir /usr/local/gfortran
        sudo ln -s /usr/local/Cellar/gcc@9/9.3.0_1/lib/gcc/9 /usr/local/gfortran/lib
        gfortran --version

@miketimofeev
Copy link
Contributor

miketimofeev commented May 12, 2021

@paulmueller Creating a symbolic link for gcc10 not working? I'm asking since you prefer gfortran 10, but link libs from version 9

    - name: Symlink gfortran (macOS)
      if: runner.os == 'macOS'
      run: |
        # make sure gfortran is available
        # https://github.com/actions/virtual-environments/issues/2524
        # https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
        sudo ln -s /usr/local/bin/gfortran-10 /usr/local/bin/gfortran
        sudo mkdir /usr/local/gfortran
        sudo ln -s /usr/local/Cellar/gcc@10/*/lib/gcc/10 /usr/local/gfortran/lib
        gfortran --version

@paulmueller
Copy link
Author

Thanks for that!

@paulmueller
Copy link
Author

For the new macOS 12 image:

    - name: Symlink gfortran (macOS)
      if: runner.os == 'macOS'
      run: |
        # make sure gfortran is available
        # https://github.com/actions/virtual-environments/issues/2524
        # https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
        sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
        sudo mkdir /usr/local/gfortran
        sudo ln -s /usr/local/Cellar/gcc@11/*/lib/gcc/11 /usr/local/gfortran/lib
        gfortran --version

@manlaya
Copy link

manlaya commented Jan 3, 2025

Thanks for the solution. It worked for me, until MacOS14 image.
For anyone wondering, here is the updated paths for MacOS14 that worked for me:

jobs:
  my_job_name:
  
  ...

    env:
      FC: gfortran
      GCC_V: 12

    steps:
  
    ... 
    
      - name: Symlink gfortran (macOS)
        if: runner.os == 'macOS'
        run: |
          # make sure gfortran is available
          # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
          # https://github.com/actions/runner-images/issues/3371
          # ln version - new path 'MacOS14'
          sudo ln -fs /opt/homebrew/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
          sudo mkdir -p /usr/local/gfortran
          sudo ln -sf /opt/homebrew/Cellar/gcc@${GCC_V}/*/lib/gcc/${GCC_V} /usr/local/gfortran/lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Apple OS: macOS question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants