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

CI problem with GH actions and macOS #343

Closed
neilyoung opened this issue May 25, 2022 · 5 comments
Closed

CI problem with GH actions and macOS #343

neilyoung opened this issue May 25, 2022 · 5 comments

Comments

@neilyoung
Copy link

You recommend to set DYLD_FALLBACK_LIBRARY_PATH

https://github.com/twistedfall/opencv-rust#:~:text=On%20macOS%20you%27re,xctoolchain/usr/lib/%22

Unfortunately Apple's System Integrity Protection disallows to set this environment variable and Github's images don't disable SIP.

Refer to:

https://apple.stackexchange.com/questions/212945/unable-to-set-dyld-fallback-library-path-in-shell-on-osx-10-11-1
actions/runner-images#650

Please also check this little GH script:

name: Test

on:
  workflow_dispatch

jobs:
  test_job:
    runs-on: macos-latest
    steps:
      - name: Test
        run: |
          echo "PATHX=$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/lib/" >> $GITHUB_ENV
          
      - name: Test
        run: |
          echo "DYLD_FALLBACK_LIBRARY_PATH=$PATHX" >> $GITHUB_ENV
      

      - name: Test
        run: |
          echo ${PATHX:-is_empty}
          echo ${DYLD_FALLBACK_LIBRARY_PATH:-is_empty}
         

The DYLD_FALLBACK_LIBRARY_PATH variable is always empty, even set correctly.

Would there be another way to satisfy the requirement of providing the lib path to the compiler?

@neilyoung
Copy link
Author

Got a hint from the Github Actions community, which seem to be a nice work around for SIP:

https://github.community/t/unable-to-set-special-environment-variable/252620/4

@neilyoung
Copy link
Author

OK, compilation is now working on Github Actions, but the result is not universally running on latest macOS (this time on a M1)

Runtime error:

~/Downloads $ ./calibration
dyld[34291]: Library not loaded: /usr/local/opt/opencv/lib/libopencv_gapi.405.dylib
  Referenced from: /Users/decades/Downloads/calibration
  Reason: tried: '/usr/local/opt/opencv/lib/libopencv_gapi.405.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib//libopencv_gapi.405.dylib' (no such file)
Abort trap: 6

Too bad. Promising, but too many external references and risks.

@neilyoung
Copy link
Author

The same binary works fine on an Intel MBP. I guess this is due to the different locations brew installs things on M1 and Intel. Since GH Actions does not have an M1 image, binaries created for "macos-latest" will only run on Intel hardware, as long as they are having external dependencies resolved by brew.

While the app (compiled on an Intel hardware) tries to find the opencv binaries under /usr/local/opt/opencv/lib, those are under /opt/homebrew/Cellar/opencv/4.5.5_2/lib/ on M1.

@twistedfall
Copy link
Owner

Thanks for the report, I'll include the reference to this issue to the readme.

@artur-zhdan
Copy link

The same binary works fine on an Intel MBP. I guess this is due to the different locations brew installs things on M1 and Intel. Since GH Actions does not have an M1 image, binaries created for "macos-latest" will only run on Intel hardware, as long as they are having external dependencies resolved by brew.

While the app (compiled on an Intel hardware) tries to find the opencv binaries under /usr/local/opt/opencv/lib, those are under /opt/homebrew/Cellar/opencv/4.5.5_2/lib/ on M1.

I am encountering the same issue.

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

No branches or pull requests

3 participants