wbond / package_control

The Sublime Text package manager
https://packagecontrol.io
4.77k stars 816 forks source link

[ST3/4] Package Control not working on macOS #1612

Closed NicosKaralis closed 7 months ago

NicosKaralis commented 2 years ago

I tried instaling the Package Control via Command Palette and even manually but it was not working, after some debugging I found that the ctypes file for python3.3 are not being correctly loaded

This is the relevant part in the debug

Traceback (most recent call last):
  File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 305, in <module>
  File "./python3.3/ctypes/__init__.py", line 366, in __getattr__
  File "./python3.3/ctypes/__init__.py", line 371, in __getitem__
AttributeError: dlsym(0x7f876fc44440, EVP_PKEY_size): symbol not found
Here is the rest of the output log

``` During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 308, in reload_plugin m = importlib.import_module(modulename) File "./python3.3/importlib/__init__.py", line 90, in import_module File "", line 1584, in _gcd_import File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/2_bootstrap.py", line 26, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/bootstrap.py", line 20, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/download_manager.py", line 24, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/downloaders/__init__.py", line 20, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/downloaders/oscrypto_downloader.py", line 44, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/tls.py", line 11, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_mac/tls.py", line 39, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_mac/util.py", line 208, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto.py", line 15, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 688, in Package Control.package_control.deps.oscrypto._ffi.FFIEngineError: Error initializing ctypes reloading python 3.3 plugin Package Control.Package Control Traceback (most recent call last): File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 305, in File "./python3.3/ctypes/__init__.py", line 366, in __getattr__ File "./python3.3/ctypes/__init__.py", line 371, in __getitem__ AttributeError: dlsym(0x7f876fc44440, EVP_PKEY_size): symbol not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 308, in reload_plugin m = importlib.import_module(modulename) File "./python3.3/importlib/__init__.py", line 90, in import_module File "", line 1584, in _gcd_import File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/Package Control.py", line 89, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/commands/__init__.py", line 3, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/commands/advanced_install_package_command.py", line 10, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 34, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/downloaders/__init__.py", line 20, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/downloaders/oscrypto_downloader.py", line 44, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/tls.py", line 11, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_mac/tls.py", line 39, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_mac/util.py", line 208, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto.py", line 15, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module exec(compile(source, source_path, 'exec'), mod.__dict__) File "/Users/nicoskaralis/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 688, in Package Control.package_control.deps.oscrypto._ffi.FFIEngineError: Error initializing ctypes ```

Any ideas on how to solve this?


Solution

Recommended solution for this issue is to manually install Package Control 4.0

[!Note]

Whether Package Control 4.0 can be installed directly via Sublime Text's main menu depends on whether the related package file will be signed and uploaded to packagecontrol.io by @wbond.

Related package download link on packagecontrol.io is also out-dated for the very same reason.

Until then run the following code snippet from within ST's console

from urllib.request import urlretrieve;urlretrieve(url="https://github.com/wbond/package_control/releases/latest/download/Package.Control.sublime-package", filename=sublime.installed_packages_path() + '/Package Control.sublime-package')

or manually

  1. download latest release from https://github.com/wbond/package_control/releases
  2. rename it to Package Control.sublime-package
  3. place it to ST's Installed Packages directory
ioctopuses commented 2 years ago

I have the same problem with MacOS 12.1. In the past, the old MacOS has installed sublime text and upgraded to 12.1. This problem does not exist. OpenSSL version 2.8.3 can be used, but OpenSSL version 3.1.0 cannot be used

df-a commented 2 years ago

Same problem here as well, on MacOS Monterrey, using OpenSSL v3.0.1

Traceback (most recent call last):
  File "/Users/aviftw/Library/Application Support/Sublime Text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 305, in <module>
  File "./python3.3/ctypes/__init__.py", line 366, in __getattr__
  File "./python3.3/ctypes/__init__.py", line 371, in __getitem__
AttributeError: dlsym(0x2214322e0, EVP_PKEY_size): symbol not found
rgaudin commented 2 years ago

For me it was due to brew-installed openssl versions conflict. I had v1.1 (works) and 3 (doesn't).

$ ls -l
/usr/local/lib/libcrypto.dylib -> /usr/local/opt/openssl@3/lib/libcrypto.dylib
$ grep EVP_PKEY_size  /usr/local/lib/libcrypto.dylib
$ grep EVP_PKEY_size /usr/local/Cellar/openssl@1.1/1.1.1n/lib/libcrypto.dylib
Binary file /usr/local/Cellar/openssl@1.1/1.1.1n/lib/libcrypto.dylib matches
# fixed by linking v1.1
$ sudo ln -sf /usr/local/Cellar/openssl@1.1/1.1.1n/lib/libcrypto.dylib /usr/local/lib/libcrypto.dyli
faelin commented 2 years ago

@rgaudin there's a typo in your final line (missing the b in dylib)

For others, the command that should fix this issue (at least on OS Monterey)


brew install openssl@1.1 && ln -sf $(set -- `brew --cellar openssl@1.1`/1.1.1? && echo "$1")/lib/libcrypto.dylib /usr/local/lib/

# or for an exact command:
ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/

EDIT: note that the command suggested by @rgaudin includes the path openssl@1.1/1.1.1n but my installation had the path openssl@1.1/1.1.1o instead, so I designed the top version of the above command to be more portable.

ashu-tosh-kumar commented 1 year ago

@rgaudin there's a typo in your final line (missing the b in dylib)

For others, the command that should fix this issue (at least on OS Monterey)

brew install openssl@1.1 && ln -sf $(set -- `brew --cellar openssl@1.1`/1.1.1? && echo "$1")/lib/libcrypto.dylib /usr/local/lib/

# or for an exact command:
ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/

EDIT: note that the command suggested by @rgaudin includes the path openssl@1.1/1.1.1n but my installation had the path openssl@1.1/1.1.1o instead, so I made the first version of the command above to be more portable.

Running ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/ solved the issue for me. Thanks.

DeveloperKev commented 1 year ago

Running ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/ solved the issue for me. Thanks.

if i install sublime text 4126 using official sublimetext, will i face this issues? or while installing brew for the first time on mac will cause this on silicon mac? i'm glad that u found a fix!

faelin commented 1 year ago

if i install sublime text 4126 using official sublimetext, will i face this issues? or while installing brew for the first time on mac will cause this on silicon mac?

Most likely, any installation on Big Sur or above will face this issue.

This issue stems from the fact that PackageControl, like many programs, still relies on older versions of OpenSSL (and is not compatible newer versions of the library). The version of the library libcrypto.dylib, which is linked from OpenSSL, is the crucial factor here. This library is not something provided by Sublime. In other words, the way you install Sublime probably doesn't matter (if the app came bundled with the appropriate library, then it wouldn't matter which method you use to install it, because the regular download doesn't use an installer wizard to pull down dependencies).

Probably, the best long term fix would be to bundle libcrypto.dylib with the PackageControl installation, to ensure correct versioning. Or to upgrade the dependency, to prevent potential SSL exploits in older versions.

EDIT: I was corrected, ST3 does ship with libcrypto, however the PackageControl implementation relies on the OS' installation instead, due to incompatibility with openssl 3.x (which is the version that ships with ST)

DeveloperKev commented 1 year ago

but in the contents of the app directory, there are libcrypto.1.1.dylib as well as libssl.1.1.dylib , so is the issue with symlink?

DeveloperKev commented 1 year ago

or can it be done in this way, that sublime will only use the backdated library instead of making it the default one.

deathaxe commented 1 year ago

Please don't quote previous comments all over the time!

That said, Package Control uses oscrypto python package for HTTPS communication, because ST2 and first releases of ST3 didn't support SSL. oscrypto relies on ssl libraries from OS as the name says.

Package Control fails loading as openssl 3 ABI changed in ways which cause import errors, so needed modules are not loaded.

Otherwise using urllib downloader would probably fix the issue as it uses ST's bundled openssl libraries these days.

nbrooks09 commented 1 year ago

I have the same issue. I am running MacOS Monterey 12.6 and a freshly installed version of Sublime Text 3 (Build 1426). When I install Package Control, it seems to install correctly but cannot be used. Package Control is not in my "ignored packages" as in some other users' issues. When I try to go into the Package Control settings - everything is greyed out (see below)

Screen Shot 2022-10-11 at 2 47 12 PM
faelin commented 1 year ago

@nbrooks09 — the screenshot you've attached appears to be an unrelated problem. You have libcrypto installed correctly, however your installation is built for the x86 architecture used by Intel macs, while your Sublime console output says that you need the arm64 build (i.e. you have an M1 mac, and therefore need the M1-compatible libcrypto).

You may be able to solve this by replacing your Homebrew installation (if you use one) to the ARM-based Homebrew, or by manually building arm64 libcrypto, or you might be able to find an answer in this openssl github issue.

If someone with an M1 mac find a solution, please let us know!

nbrooks09 commented 1 year ago

@faelin thanks for this!

I had the ARM-based Homebrew installed already.

What worked for me was to move libcrypto.dylib.

FichteFoll commented 1 year ago

I have the same problem on Arch Linux now where it appears to find libcrypto.so.3 instead of the also available libcrypto.so.1.1

reloading python 3.3 plugin Package Control.2_bootstrap
Traceback (most recent call last):
  File "/home/mhm/.config/sublime-text/Packages/Package Control/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 305, in <module>
    P_EVP_PKEY
  File "./python3.3/ctypes/__init__.py", line 366, in __getattr__
  File "./python3.3/ctypes/__init__.py", line 371, in __getitem__
AttributeError: /usr/lib/libcrypto.so.3: undefined symbol: EVP_PKEY_size

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/2_bootstrap.py", line 26, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/bootstrap.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/download_manager.py", line 24, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/downloaders/__init__.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/downloaders/oscrypto_downloader.py", line 44, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/tls.py", line 23, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/tls.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libssl.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto.py", line 15, in <module>
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/mhm/.config/sublime-text/Packages/Package Control/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 688, in <module>
    raise FFIEngineError('Error initializing ctypes')
Package Control.package_control.deps.oscrypto._ffi.FFIEngineError: Error initializing ctypes

There is functionality in oscrypto to override library paths via a _backend_config dict that seems to be initialized during the use_openssl call, but I failed to see a configuration available to the end user to override this within Package Control.

By creating an override file that corrects the path that oscrypto tries to load libcrypto for, I am able to initialize Package Control again.

--- Installed Packages/Package Control/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py  2020-10-02 10:34:52
+++ Packages/Package Control/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py    2022-11-28 14:47:20
@@ -23,7 +23,7 @@

 libcrypto_path = _backend_config().get('libcrypto_path')
 if libcrypto_path is None:
-    libcrypto_path = get_library('crypto', 'libcrypto.dylib', '42')
+    libcrypto_path = get_library('crypto.so.1', 'libcrypto.dylib', '42')
 if not libcrypto_path:
     raise LibraryNotFoundError('The library libcrypto could not be found')

Interestingly other packages that try to import things from the PC library (such as the AutomaticPackageReloader importing as PackageManager) fail to load and raise the exception above, even though both are inside of the 3.3 plugin host and the module is available:

``` reloading python 3.3 plugin AutomaticPackageReloader33.package_reloader Traceback (most recent call last): File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 305, in File "./python3.3/ctypes/__init__.py", line 366, in __getattr__ File "./python3.3/ctypes/__init__.py", line 371, in __getitem__ AttributeError: /usr/lib/libcrypto.so.3: undefined symbol: EVP_PKEY_size During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 308, in reload_plugin m = importlib.import_module(modulename) File "./python3.3/importlib/__init__.py", line 90, in import_module File "", line 1584, in _gcd_import File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "", line 584, in _check_name_wrapper File "", line 1022, in load_module File "", line 1003, in load_module File "", line 560, in module_for_loader_wrapper File "", line 868, in _load_module File "", line 313, in _call_with_frames_removed File "/home/mhm/.config/sublime-text/Packages/AutomaticPackageReloader33/package_reloader.py", line 1, in from AutomaticPackageReloader import package_reloader as package_reloader38 # noqa File "/home/mhm/.config/sublime-text/Packages/AutomaticPackageReloader/package_reloader.py", line 8, in from .reloader import reload_package File "/home/mhm/.config/sublime-text/Packages/AutomaticPackageReloader/reloader/__init__.py", line 1, in from .reloader import reload_package, load_dummy File "/home/mhm/.config/sublime-text/Packages/AutomaticPackageReloader/reloader/reloader.py", line 13, in from .resolver import resolve_parents File "/home/mhm/.config/sublime-text/Packages/AutomaticPackageReloader/reloader/resolver.py", line 2, in from package_control.package_manager import PackageManager File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 34, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/downloaders/__init__.py", line 20, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/downloaders/oscrypto_downloader.py", line 44, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/tls.py", line 23, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/tls.py", line 10, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libssl.py", line 7, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto.py", line 15, in File "", line 1565, in _find_and_load File "", line 1532, in _find_and_load_unlocked File "/home/mhm/.config/sublime-text/Installed Packages/Package Control.sublime-package/package_control/deps/oscrypto/_openssl/_libcrypto_ctypes.py", line 688, in package_control.deps.oscrypto._ffi.FFIEngineError: Error initializing ctypes >>> import sys >>> {k: v for k, v in sys.modules.items() if "libcrypto" in k} {} Python 3.3>>> import sys Python 3.3>>> {k: v for k, v in sys.modules.items() if "libcrypto" in k} {'Package Control.package_control.deps.oscrypto._openssl._libcrypto_ctypes': , 'Package Control.package_control.deps.oscrypto._openssl._libcrypto': } ```
deathaxe commented 1 year ago

I'd be curious whether it stil happens in four-point-oh branch as it ships with latest oscrypto libs.

FichteFoll commented 1 year ago

I can try that out some time later if I don't forget. Is there anything else I need to consider before just cloning the repo into my Packages folder?

deathaxe commented 1 year ago

Basically not, I hope. I've tested migration from PC3.x to PC4 several times with success on Windows and Linux (Elementary OS). It should convert the library structure (move all to Lib) and should be ready after a single restart of ST.

The only limitation so far is libraries being reinstalled rather than updated when calling Satisfy Libraries as required PEP404 and PEP508 version comparison is not yet applied.

I use that branch in production without noticible issues however.

FichteFoll commented 1 year ago

Quick update, since my local setup became so broken I needed to update my packages and wasn't able to go around this anymore. Following are my steps and observations during the update process:

  1. Close ST.
  2. Removed Package Control from Installed Packages and clone into Packages (master branch!).
  3. Start ST, packages are updated (=> the problem appears to be fixed in master already)
  4. Close ST.
  5. Checkout four-point-oh branch.
  6. Start ST, wait for the PC popup asking me to restart, close ST.
  7. Start ST, wait for the PC popup asking me to restart, close ST.
  8. Start ST, no popup anymore and also almost no tracebacks in the console anymore except for this one:
``` Traceback (most recent call last): File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 528, in on_api_ready plc() File "/home/fichte/.config/sublime-text/Installed Packages/SublimeLinter.sublime-package/sublime_linter.py", line 54, in plugin_loaded package_control.events.install('SublimeLinter') or AttributeError: 'module' object has no attribute 'events' ``` ~~There should probably be a fake module for compatibility after the update here.~~ ~~There seems to be one already but not sure why SL doesn't have it.~~ SL doesn't import `package_control.events`. Raising upstream. https://github.com/SublimeLinter/SublimeLinter/pull/1889 ``` >>> import package_control >>> import package_control.events >>> package_control.events >>> package_control.events.install Python 3.3>>> import package_control Python 3.3>>> import package_control.events Python 3.3>>> package_control.events.install ```
CodeByZach commented 1 year ago

The solution put forth by @faelin worked for me. I ended up running the following: ln -sf /usr/local/Cellar/openssl@1.1/1.1.1u/lib/libcrypto.dylib /usr/local/lib/

@faelin Thank you!!

Arbior commented 1 year ago

On my Mac, with Ventura, the path was slightly different (1.1.1u -> 1.1.1k). Running ln -sf /usr/local/Cellar/openssl@1.1/1.1.1k/lib/libcrypto.dylib /usr/local/lib/ solved the problem.

PS: the problem occurred after the installation of BeautifyLatex with LatexIndent.

deathaxe commented 1 year ago

For those who having trouble due to OpenSSL and some time for testing could checkout PC 4.0-beta.

To do so:

  1. create a backup of your ST profile including all packages in case you want or need to roll back!
  2. Open Command Palette and call Preferences: Package Control Settings
  3. add "Package Control" to the list of "install_prereleases" as followed:

    "install_prereleases":
    [
        "Package Control",
    ],
    
  4. Open Command Palette and call Package Control: Update Package
  5. Select "Package Control" and hit enter

Package Control 4.0 uses latest oscrypto library which should support OpenSSL 3.

Warning

Make a backup of your data!

PC4.0 converts dependencies to libraries and installs them to "Data\Lib\python3.x" folder.

inferiorhumanorgans commented 12 months ago

The solution put forth by @faelin worked for me. I ended up running the following: ln -sf /usr/local/Cellar/openssl@1.1/1.1.1u/lib/libcrypto.dylib /usr/local/lib/

@faelin Thank you!!

This is a bad idea as it will break anything that expects the default library to be OpenSSL 3.

inferiorhumanorgans commented 12 months ago
 "install_prereleases":
 [
  "Package Control",
 ],

Is there any way to bootstrap this?

deathaxe commented 12 months ago

Package Control will be uppraded next time package update is triggered, either by automatic updates at ST startup or by manually calling "Package Control: Upgrade All Packages/Overwrite All" via Command Palette.

In case PC3.x is not working, you can

  1. download https://github.com/wbond/package_control/releases/download/4.0.0-beta8/Package.Control.sublime-package
  2. call Main Menu > Preferences > Browse Packages...
  3. navigate to to ../Installed Packages
  4. move downloaded package into Installed Packages and rename it to Package Control.sublime-package (replace the . by ).
brian-farrell commented 12 months ago

@deathaxe The file that gets downloaded in your instructions above is named 'Package.Control.sublime-package'

I found that I needed to rename the file to 'Package Control.sublime-package' in order for this fix to work. (I changed the first Period, after the word 'Package' to a space)

Also needed to restart ST3.

Package Control appears to be working again as expected after this.

inferiorhumanorgans commented 12 months ago

Package Control will be uppraded next time package update is triggered, either by automatic updates at ST startup or by manually calling "Package Control: Upgrade All Packages/Overwrite All" via Command Palette.

In case PC3.x is not working, you can

1. download https://github.com/wbond/package_control/releases/download/4.0.0-beta2/Package.Control.sublime-package

2. call _Main Menu > Preferences > Browse Packages..._

3. navigate to to _../Installed Packages_

4. move _Package Control.sublime-package_ to ST's _Installed Packages_

Right, but that only works if PC has been installed and bootstrapped. On a clean install these steps don't work.

deathaxe commented 12 months ago

@brian-farrell That's unfortunatelly a restriction of GitHub download artefacts, that whitespace is automatically replaced by period.

Forgot about that.

@inferiorhumanorgans Package Control bootstraps itself. There's nothing more to do, than placing it into Installed Packages. Maybe a restart is needed after it was loaded the first time. but that's it. Please check file name. The download artefact contains an unwanted period.

gerardroche commented 11 months ago

My unit tests for osx have started failing. I assume it's related to this issue. It times out when trying to install Package Control:

...
/Users/runner/work/NeoVintageous/NeoVintageous
Run . $GITHUB_ACTION_PATH/../../scripts/utils.sh
copy the package to sublime package directory
/Users/runner/work/NeoVintageous/NeoVintageous
Installing UnitTesting from https://github.com/SublimeText/UnitTesting@1.5.9 to /Users/runner/Library/Application Support/Sublime Text/Packages/UnitTesting
Installing coverage from https://github.com/codexns/sublime-coverage@1.0.0 to /Users/runner/Library/Application Support/Sublime Text/Packages/coverage
Run bash $GITHUB_ACTION_PATH/../../scripts/install_package_control.sh
creating Package Control.sublime-settings
/Users/runner/work/_actions/SublimeText/UnitTesting/v1/actions/setup/../../scripts/install_package_control.sh: line 67:  1293 Terminated: 15          subl
/Users/runner/work/_actions/SublimeText/UnitTesting/v1/actions/setup/../../scripts/install_package_control.sh: line 67:  1873 Terminated: 15          subl
/Users/runner/work/_actions/SublimeText/UnitTesting/v1/actions/setup/../../scripts/install_package_control.sh: line 67:  2060 Terminated: 15          subl
....................................Timeout: Fail to install Package Control.
Error: Process completed with exit code 1.

https://github.com/NeoVintageous/NeoVintageous/actions/runs/5601698773

Is there anything I need to do or will fixed upstream in time?

deathaxe commented 11 months ago

It would require PC4.0 to be released and the sublime-package file being uploaded to packagecontrol.io or Unittest to be tweaked to use PC4.0 beta builds. Whatever happens first (or ever).

cht21 commented 11 months ago

Package Control will be uppraded next time package update is triggered, either by automatic updates at ST startup or by manually calling "Package Control: Upgrade All Packages/Overwrite All" via Command Palette.

In case PC3.x is not working, you can

1. download https://github.com/wbond/package_control/releases/download/4.0.0-beta2/Package.Control.sublime-package

2. call _Main Menu > Preferences > Browse Packages..._

3. navigate to to _../Installed Packages_

4. move downloaded package into _Installed Packages_ and rename it to _Package Control.sublime-package_ (replace the `.` by ` `).

Thanks, this worked for me on Ventura 13.4 after a clean install of ST4. Moving the file to "Installed Packages" made the difference. There's another thread on Github saying it should be placed in "Packages", but that didn't do the trick.

DiegoAz commented 11 months ago

@deathaxe after moving to ../Installed Packages Package Control.sublime-package v4.0.0-beta2 (tried beta3 and beta4 too) the package LSP-pyright (or LSP?) stops working properly. If I go back to version 3.4.1 LSP-pyright works correctly. Do you know another option for package control to work together with LSP-pyright? I am running MacOS Monterrey 12.6.7 (21G651), Sublime Text 4143 (freshly installed state)

deathaxe commented 11 months ago

PC 4.0 moves all dependencies such as _lsputils from Data/Packages/ to Data/Lib/python33 to make them available for import without needing _00_package_controlloader plugin and to tidy up Data/Packages.

Except some "plugin-like" functions of some dependencies from no longer being available, it shouldn't effect how plugins work.

In fact I am using LSP and LSP-pyright (or any other LSP-helper) without issues on python 3.3 (and with some local tweaks even on python 3.8) plugin_host.

Once dependencies have been moved, you might need to completely exit and restart ST for changes to take effect.

DiegoAz commented 11 months ago

@deathaxe I just installed PC 4.0 beta4, LSP and LSP-pyright and everything works as expected and it worked instantly. Thanks. I think I might have messed up yesterday when I modified the $PATH in ~/.zprofile

eugconrad commented 11 months ago

@rgaudin there's a typo in your final line (missing the b in dylib)

For others, the command that should fix this issue (at least on OS Monterey)

brew install openssl@1.1 && ln -sf $(set -- `brew --cellar openssl@1.1`/1.1.1? && echo "$1")/lib/libcrypto.dylib /usr/local/lib/

# or for an exact command:
ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/

EDIT: note that the command suggested by @rgaudin includes the path openssl@1.1/1.1.1n but my installation had the path openssl@1.1/1.1.1o instead, so I designed the top version of the above command to be more portable.

Running ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/lib/libcrypto.dylib /usr/local/lib/ solved the issue for me too. Thank you so much!

Caffeinated-Python commented 11 months ago

For anyone still having this issue and has homebrew installed, unlinking openssl from homebrew resolved the issue for me.

tldr at the bottom

Steps 1) Close and fully quit the Sublime Text editor. 2) In a terminal, enter the following command: brew unlink openssl (on my system, takes around ~ 10 seconds to finish) 3) Open the Sublime Text editor, open then Command palette (Command + Shift + P): Enter 'Install Package Control' and select the drop down option, you should get the text: "Package Control was successfully installed Use the Command Palette and type "Install Package" to get started"

4) Click ok, open the command palette again, and enter the text 'Package control'. One should be able to see the various Package Control options available (List Packages, Remove Package, Advanced Install Package, etc...)

Note - if you don't see any of the Package Control options, try fully closing and quitting Sublime Text again. You can verify Sublime Text is fully terminated by checking for the Sublime Text process to drop (disappear) in the Activity Center application. I found some instances in which I had to open and quit Sublime Text a few times before the package control options finally appear listed in the Command Palette.

5) Perform whatever package installations, removals, etc you need to to. 6) In the terminal again, enter brew link openssl

Caveat - the packages I've installed and used are still functional after using brew link openssl. There maybe certain use cases in which the steps above may not work for you.

Not exactly the most elegant approach, it still leaves Package control in a broken state but for anyone that is hesitant on using the ln -sf approach or downloading/renaming/moving installation files around, this workaround may be suffice until a more permanent solution is pushed up.

System info used for test: Fresh install of Big Sur (11.7.9) and fresh install of Sublime Text 4 (stable channel, build 4152). Packages used: HTML-CSS-JS Prettyify, Pretty JSON, Json Colors and Navigation. Homebrew 4.1.3 Homebrew/homebrew-core (git revision 001bcd2372d; last commit 2023-08-02) /usr/local/Cellar/openssl@3/3.1.2

tldr - Fully quit sublime text, in a terminal use brew unlink openssl, use package control for whatever needs you have, brew link openssl in a terminal to return to your original state.

aremmell commented 11 months ago

For me it was due to brew-installed openssl versions conflict. I had v1.1 (works) and 3 (doesn't).

$ ls -l
/usr/local/lib/libcrypto.dylib -> /usr/local/opt/openssl@3/lib/libcrypto.dylib
$ grep EVP_PKEY_size  /usr/local/lib/libcrypto.dylib
$ grep EVP_PKEY_size /usr/local/Cellar/openssl@1.1/1.1.1n/lib/libcrypto.dylib
Binary file /usr/local/Cellar/openssl@1.1/1.1.1n/lib/libcrypto.dylib matches
# fixed by linking v1.1
$ sudo ln -sf /usr/local/Cellar/openssl@1.1/1.1.1n/lib/libcrypto.dylib /usr/local/lib/libcrypto.dyli

This was still an issue in 2023–having openssl@3 installed in brew breaks package control–symlink fixes the issue.

dhempy commented 11 months ago

Wow...two years later and sublime still doesn't support the latest openssl? I've got a persnickety development stack for work (I know...) and I'm not inclined to hack around this problem to get my editor working as it did a week ago.

I upgraded to build 4152 in the last week or so, and now all Package Control commands are missing from my Command Palette. "Install Package Control" is not on the Tools menu. (I can't pinpoint that it disappeared with the 4152 upgrade, but I am certain I used Package Control within the last month.)

Are others seeing this with the 4152 update?

deathaxe commented 11 months ago

Package Control not being loaded is not related with ST version, but solely is related with OS's default openssl version, which has been pointed out in this issue a dozens of times - as the two solutions to that issue have been.

ST won't support openssl 3 anytime soon as backporting it into python 3.3 plugin_host is not too easy (see https://github.com/sublimehq/sublime_text/issues/5984).

pwenzel commented 11 months ago

Wow...two years later and sublime still doesn't support the latest openssl? I've got a persnickety development stack for work (I know...) and I'm not inclined to hack around this problem to get my editor working as it did a week ago.

I upgraded to build 4152 in the last week or so, and now all Package Control commands are missing from my Command Palette. "Install Package Control" is not on the Tools menu. (I can't pinpoint that it disappeared with the 4152 upgrade, but I am certain I used Package Control within the last month.)

Are others seeing this with the 4152 update?

I am experiencing the same behavior with Sublime Text 4 build 4152 on Mac OS Monterey 12.6.7.

Installing openssl@1.1 with brew as noted above fixed it, at least for the moment.

TKOxff commented 11 months ago

The solution put forth by @faelin worked for me. I ended up running the following: ln -sf /usr/local/Cellar/openssl@1.1/1.1.1u/lib/libcrypto.dylib /usr/local/lib/

ln -sf /opt/homebrew/Cellar/openssl@1.1/1.1.1u/lib/libcrypto.dylib /usr/local/lib/

It works for me too, but the base path is different on Apple M2 Pro, macOS Ventura 13.5

abjugard commented 11 months ago

Package Control not being loaded is not related with ST version, but solely is related with OS's default openssl version, which has been pointed out in this issue a dozens of times - as the two solutions to that issue have been.

ST won't support openssl 3 anytime soon as backporting it into python 3.3 plugin_host is not too easy (see sublimehq/sublime_text#5984).

Then they'll have to ship and maintain a hardened version of openssl 1.1.

CodeByZach commented 11 months ago

@wbond @deathaxe This is now affecting a lot of users. Any way we can either standardize a proper patch or ship one out in the next version? Thanks

deathaxe commented 11 months ago

Actually Package Control 4.0-beta already contains a fix. I already proposed installing it various posts before or at https://github.com/sublimehq/sublime_text/issues/6037#issuecomment-1674337039.

I can't however sign or upload a Package Control.sublime-package to official packagecontrol.io website, which was required for a final release artefact to be installable directly by ST's installer.

rchl commented 11 months ago

Don't you think that there should be some controlled release of 4.0 to only a small number of users to verify that it works as expected? I know that some people already use it by manually installing it but that's not quite the same as using the auto-update to install the 4.0 version.

I feel that releasing 4.0 hastily can cause more damage than good.

deathaxe commented 11 months ago

How do you want to achieve something like that?

The only mechanism to limit effected users is the install_prereleases key, which requires opt-in on users end. I don't see an automated way to do rollout in waves.

I am however more concerned about a release being limited in use as long as packagecontrol.io doesn't support python 3.8.

But that's off-topic here.

rchl commented 11 months ago

So I guess the closest to the real release would be by using install_prereleases but with package control 4 actually deployed to the servers instead of having to download it manually. Then there could be a call on Discord for more people to test it. There can only be one chance of upgrading from v3 to v4 so it's probably best to test that once v4 is 99.9% ready rather than testing early and then later beta version potentially breaking something in the upgrade process.

deathaxe commented 11 months ago

All 4.0.0-beta builds have been available this way. Not sure what you want more.

rchl commented 11 months ago

I was basing my comment on https://github.com/sublimehq/sublime_text/issues/6037#issuecomment-1674337039 where your instructions imply that you have to download release manually (steps 1 and 2).

faelin commented 10 months ago

I just installed the 4.0 release manually, after my current machine ran into the lib-crypto / openssl issue.

Install worked perfectly on Mac OS Ventura (13.5), no further tweaking of libraries required!

benfrain commented 10 months ago

Unsure if this is the same issue. Having installed v4, I get this in the console:

Package Control: Installing 16 libraries...
Package Control: The library "wcwidth" is not available for Python 3.3
Package Control: The library "pathlib" is not available for Python 3.3
Package Control: The library "python-markdown" is not available for Python 3.3
Package Control: The library "backrefs" is not available for Python 3.3
Package Control: The library "ptyprocess" is not available for Python 3.3
Package Control: The library "pymdownx" is not available for Python 3.3
Package Control: The library "sublime_lib" is not available for Python 3.3
Package Control: The library "python-jinja2" is not available for Python 3.3
Package Control: The library "bracex" is not available for Python 3.3
Package Control: The library "pyte" is not available for Python 3.3
Package Control: The library "pyyaml" is not available for Python 3.3
Package Control: The library "pygments" is not available for Python 3.3
Package Control: The library "lsp_utils" is not available for Python 3.3
Package Control: The library "markupsafe" is not available for Python 3.3
Package Control: The library "mdpopups" is not available for Python 3.3
Package Control: The library "wcmatch" is not available for Python 3.3