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

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

Closed
2 tasks
eligundry opened this issue Dec 9, 2021 · 6 comments · Fixed by #64924
Closed
2 tasks

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

eligundry opened this issue Dec 9, 2021 · 6 comments · Fixed by #64924
Assignees
Labels
Bug broken, incorrect, or confusing behavior dependency underlying Salt dependency issue doc-rework confusing, misleading, or wrong Documentation Relates to Salt documentation MacOS pertains to the OS of fruit severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around time-estimate-single-day
Milestone

Comments

@eligundry
Copy link
Contributor

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. [BUG][MacOS] Salt errors on macOS Big Sur #57787
  2. [RC1 Sodium] salt fails on macOS Catalina, due to loading unversioned /usr/lib/libcrypto.dylib #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!

@eligundry eligundry added Bug broken, incorrect, or confusing behavior needs-triage labels Dec 9, 2021
@OrangeDog OrangeDog added dependency underlying Salt dependency issue MacOS pertains to the OS of fruit labels Dec 9, 2021
@jpmckinney
Copy link
Contributor

jpmckinney commented 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: #57742

@eligundry
Copy link
Contributor Author

Oh interesting. This seems to have fixed my immediate issue, I just need to figure out how to private env vars for sudo so I'm not running this as root. Thanks for this.

@waynew
Copy link
Contributor

waynew commented Dec 14, 2021

It may be worthwhile to add a note to the documentation for this.

@waynew waynew added this to the Approved milestone Dec 14, 2021
@waynew waynew added the Documentation Relates to Salt documentation label Dec 14, 2021
@waynew
Copy link
Contributor

waynew commented Dec 14, 2021

Could be added to this page: https://docs.saltproject.io/en/latest/topics/installation/osx.html

@eligundry
Copy link
Contributor Author

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.

@barbaricyawps barbaricyawps added severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around time-estimate-single-day doc-rework confusing, misleading, or wrong labels Jan 18, 2022
@csautter
Copy link

It's just a sudo related Problem.
Running salt-call with sudo don't pass the environment variables.
Just run sudo -E salt-call to preserve the environment variables and it works like a charm.

% sudo --help
  -E, --preserve-env            preserve user environment when running command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior dependency underlying Salt dependency issue doc-rework confusing, misleading, or wrong Documentation Relates to Salt documentation MacOS pertains to the OS of fruit severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around time-estimate-single-day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants