jaredks / rumps

Ridiculously Uncomplicated macOS Python Statusbar apps
BSD 3-Clause "New" or "Revised" License
3.06k stars 177 forks source link

Does anyone know how to fix a "(no such file), '/System/Library/Carbon.framework/Carbon' (no such file, not in dyld cache)" error? #208

Open Dima-369 opened 9 months ago

Dima-369 commented 9 months ago

This happens on a M1 macOS 14.0.

test.py

import rumps

class BarApp(rumps.App):
    @rumps.clicked("Test")
    def test(self, _):
        rumps.alert("Now click BarApp twice, then click OK.\nResult: segfault")

BarApp("BarApp").run()

setup.py

from setuptools import setup

APP = ['test.py']
DATA_FILES = []
OPTIONS = {
    'argv_emulation': True,
    'plist': {
        'LSUIElement': True,
    },
    'packages': ['rumps'],
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

The error

~/rumps test/dist/test.app/Contents/MacOS $ ./test

Traceback (most recent call last):
  File "/Users/dima/rumps test/dist/test.app/Contents/Resources/__boot__.py", line 321, in <module>
    _argv_emulation()
  File "/Users/dima/rumps test/dist/test.app/Contents/Resources/__boot__.py", line 318, in _argv_emulation
    _run_argvemulator()
  File "/Users/dima/rumps test/dist/test.app/Contents/Resources/__boot__.py", line 127, in _run_argvemulator
    carbon = _ctypes_setup()
             ^^^^^^^^^^^^^^^
  File "/Users/dima/rumps test/dist/test.app/Contents/Resources/__boot__.py", line 51, in _ctypes_setup
    carbon = ctypes.CDLL("/System/Library/Carbon.framework/Carbon")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ctypes/__init__.pyc", line 376, in __init__
OSError: dlopen(/System/Library/Carbon.framework/Carbon, 0x0006): tried: '/System/Library/Carbon.framework/Carbon' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/System/Library/Carbon.framework/Carbon' (no such file), '/System/Library/Carbon.framework/Carbon' (no such file, not in dyld cache)
2023-10-11 21:16:10.885 test[81802:3058374] Launch error
2023-10-11 21:16:10.885 test[81802:3058374] Launch error
See the py2app website for debugging launch issues
jksmx commented 8 months ago

Same problem

QAInsights commented 7 months ago

Same here for M2.

QAInsights commented 7 months ago

@Dima-369 @jksmx I fixed the issue. Here is my setup.py. Please make sure that 'argv_emulation' is False as shown below and DATA_FILES must be list[tuple[str, list[str]]].

This is my Hamster project. Hope I saved your day :)

APP = ['hamster/__main__.py']
APP_NAME = 'Hamster'
DATA_FILES = [('', ['hamster/app.properties']), ('img', ['hamster/img/hamster.png'])]
OPTIONS = {
    'argv_emulation': False,
    'iconfile': 'hamster/img/hamster.png',
    'plist': {
        'LSUIElement': True,
    },
    'packages': ['rumps', 'configparser', 'plistlib', 'os', 're', 'pathlib', 'psutil'],
}
Dima-369 commented 7 months ago

Please make sure that 'argv_emulation' is False

Cool, this also works for me. Thanks 🙂

matagus commented 7 months ago

this worked for me too, thanks!