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

Fix MacOS builds: OSError: dlopen(libusb-1.0.dylib, 6): image not found #87

Closed
maltfield opened this issue Jul 27, 2024 · 5 comments
Closed

Comments

@maltfield
Copy link
Member

This issue will track the effort to fix our currently-broken MacOS builds, which produce the following error when attempting to arm buskill

00:52:06,27 packages.buskill DEBUG DEBUG: Exception thrown in child process: Failed to load dynlib/dll 'libusb-1.0.dylib'. Most likely this dynlib/dll was not found when the application was frozen.

00:52:06,37 packages.buskill DEBUG DEBUG: Traceback: Traceback (most recent call last):
  File "PyInstaller/loader/pyimod03_ctypes.py", line 53, in __init__
  File "ctypes/__init__.py", line 379, in __init__
OSError: dlopen(libusb-1.0.dylib, 6): image not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "buskill/__init__.py", line 1632, in run
    multiprocessing.Process.run(self)
  File "multiprocessing/process.py", line 108, in run
  File "buskill/__init__.py", line 1104, in armNix
    with usb1.USBContext() as context:
  File "usb1/__init__.py", line 2144, in __enter__
  File "usb1/__init__.py", line 2174, in open
  File "usb1/_libusb1.py", line 210, in loadLibrary
  File "usb1/_libusb1.py", line 219, in __loadLibrary
  File "usb1/_libusb1.py", line 158, in __getLibrary
  File "PyInstaller/loader/pyimod03_ctypes.py", line 55, in __init__
pyimod03_ctypes.install.<locals>.PyInstallerImportError: Failed to load dynlib/dll 'libusb-1.0.dylib'. Most likely this dynlib/dll was not found when the application was frozen.

This issue was discovered when attempting to solve #77

@maltfield
Copy link
Member Author

Currently, the MacOS builds finish "successfully". And I'm able to download, "install", and execute the BusKill app.

I only get an error (now correctly captured by the GUI thanks to the commits earlier today when clicking the "arm" button.

It appears that the libusb-1.0.dylib file is missing from the BusKill macOS app, which is needed for the non-root child process (referenced as usb_handler) to watch for usb hotplug events (whoose callback executes the trigger function).

The change that most-likely broke this was the software bumps done in #78

In ^ that ticket, we changed from libusb-1.0.23.tar.bz2 to libusb-1.0.27.tar.bz2

@maltfield
Copy link
Member Author

I thought that maybe all I needed to do was to update 1.0.23 to 1.0.27 in a few places in the build script (and, indeed, those were never updated), but I unfortunately also discovered that there is no files named dylib in the new tarball

user@buskill:/tmp/libusb-1.0.27$ find . | grep -i dylib
user@buskill:/tmp/libusb-1.0.27$ 

...so this might be more complicated than initially expected

@maltfield
Copy link
Member Author

huh, I downloaded and extracted all the libusb releases from 1.0.23 until today, and none of them had any dylib files. I guess I got it from someplace else

user@disp187:~/Downloads/libusb$ ls
libusb-1.0.23              libusb-1.0.24.tar.bz2  libusb-1.0.26-rc1.tar.bz2  libusb-1.0.27-rc2
libusb-1.0.23.tar.bz2      libusb-1.0.25          libusb-1.0.26.tar.bz2      libusb-1.0.27-rc2.tar.bz2
libusb-1.0.24              libusb-1.0.25.tar.bz2  libusb-1.0.27              libusb-1.0.27.tar.bz2
libusb-1.0.24-rc1          libusb-1.0.26          libusb-1.0.27-rc1
libusb-1.0.24-rc1.tar.bz2  libusb-1.0.26-rc1      libusb-1.0.27-rc1.tar.bz2
user@disp187:~/Downloads/libusb$ 

user@disp187:~/Downloads/libusb$ find . | grep -i dylib
user@disp187:~/Downloads/libusb$

maltfield added a commit that referenced this issue Jul 28, 2024
@maltfield
Copy link
Member Author

maltfield commented Jul 28, 2024

oh, duh, the dylib file doesn't exist in the tarball. It gets created after we make it

cp build/deps/libusb-1.0.23.tar.bz2 /tmp/
pushd /tmp
tar -xjvf libusb-1.0.23.tar.bz2
pushd libusb-1.0.23
./configure
make
popd
popd
find /tmp | grep -i dylib
cp /tmp/libusb-1.0.23/libusb/.libs/libusb-1.0.dylib src/

@maltfield
Copy link
Member Author

After ^ that change, the latest build now runs without throwing an error upon arming.

This is fixed

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

1 participant