[BUG] `OSError: Cannot locate OpenSSL libcrypto` on MacOS + M1 Mac

See original GitHub issue

Description

Hi all, I just got a new Macbook Pro M1 running MacOS Monteray (12.0.1) and I’m trying to set it up using my Salt states. Unfortunately, I cannot get Salt to run after installing the latest version in Homebrew.

❯ sudo salt-call
Password:
Traceback (most recent call last):
  File "/opt/homebrew/bin/salt-call", line 8, in <module>
    sys.exit(salt_call())
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/scripts.py", line 426, in salt_call
    import salt.cli.call
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/cli/call.py", line 3, in <module>
    import salt.cli.caller
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/cli/caller.py", line 15, in <module>
    import salt.minion
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/minion.py", line 24, in <module>
    import salt.crypt
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/crypt.py", line 31, in <module>
    import salt.utils.rsax931
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/utils/rsax931.py", line 142, in <module>
    libcrypto = _init_libcrypto()
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/utils/rsax931.py", line 95, in _init_libcrypto
    libcrypto = _load_libcrypto()
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/utils/rsax931.py", line 88, in _load_libcrypto
    return cdll.LoadLibrary(_find_libcrypto())
  File "/opt/homebrew/Cellar/salt/3004/libexec/lib/python3.10/site-packages/salt/utils/rsax931.py", line 80, in _find_libcrypto
    raise OSError("Cannot locate OpenSSL libcrypto")
OSError: Cannot locate OpenSSL libcrypto

I have done a fair amount of Googling and looking at the issues in this repo and I’m seeing the following:

  1. https://github.com/saltstack/salt/issues/57787
  2. https://github.com/saltstack/salt/issues/55084

I have tried some of the fixes outlined here, like symlinking the dylibs to various places and making sure I have the latest version of cryptography installed, but alas, this still isn’t working.

Setup Use an M1 Mac on 12.0.1 and brew install saltstack

Steps to Reproduce the behavior

  • brew install saltstack
  • sudo salt-call

Expected behavior

I think salt-call without any arguments outputs the usage info?

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
❯ salt --versions-report
Salt Version:
          Salt: 3004

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.0
     docker-py: Not Installed
         gitdb: 4.0.5
     gitpython: 3.1.12
        Jinja2: 2.11.3
       libgit2: 1.3.0
      M2Crypto: Not Installed
          Mako: 1.1.4
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.19
      pycrypto: 3.11.0
  pycryptodome: 3.9.8
        pygit2: 1.7.0
        Python: 3.10.0 (default, Oct 22 2021, 13:24:07) [Clang 13.0.0 (clang-1300.0.29.3)]
  python-gnupg: 0.4.4
        PyYAML: 5.4.1
         PyZMQ: 21.0.2
         smmap: 3.0.2
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: darwin 21.1.0
        locale: utf-8
       machine: arm64
       release: 21.1.0
        system: Darwin
       version: 12.0.1 arm64

Additional context Thanks Salt team, y’all are doing the best you can and I very much appreciate it! I hope your holidays are safe and happy!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jpmckinneycommented, Dec 9, 2021

Homebrew on M1 installs in /opt/homebrew. https://github.com/saltstack/salt/blob/master/salt/utils/rsax931.py#L35 assumes that the prefix is /usr/local.

You can change the prefix for now using env HOMEBREW_PREFIX=/opt/homebrew ahead of your Salt command.

Ideally, the code will check both paths, since M1 machines can still use /usr/local if they run Homebrew under Rosetta.

That said, I now get TypeError: cannot pickle '_thread._local' object which I need to look into. Looks like that issue is: https://github.com/saltstack/salt/issues/57742

0reactions
eligundrycommented, Dec 14, 2021

I would 👍 the documentation and I would also say that it maybe makes sense to be able to handle this without the env var needing to be set. If Salt can detect that it’s installed in /opt/Homebrew, it might be safe to add that to the path search for these libraries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: OpenSSL on Apple Silicon: libcrypto.dylib, building for ...
Are you using a M1 Mac? From the error output, you have Homebrew installed under /usr/local , which indicates you're using a x86...
Read more >
Xcode error: building for iOS Simu… | Apple Developer Forums
This error indicates that OpenSSL is built containing the simulator slice (x86_64) with the iOS device slice (arm64). Combining device and simulator into...
Read more >
M1 mac: mach-o file, but is an incompatible architecture (have ...
This is no problem for pure python modules. However if the wheel should contain C code that has to be compiled then I...
Read more >
osx mysql error dyld: Library not loaded: /usr/local/opt/openssl/lib ...
OSX Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib ... install packages due to an oserror: [winerror 2] the system cannot find the file ...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/21 06 ...
src/plugins/quota/rquota.h: No such file or directory" status:UNCONFIRMED ... utils ported from OSX, supplies mkfs and fsck" status:UNCONFIRMED resolution: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found