dandavison / open-in-editor

Open a local file from a URL at a line number in an editor/IDE
55 stars 8 forks source link

Broken on latest MacOS #10

Closed jensbodal closed 2 years ago

jensbodal commented 2 years ago

Apple decided to remove python2 in latest MacOS. So there is no longer a /usr/bin/python binary and it’s quite convoluted to re-populate it with a symlink due to SIP.

I was able to get around this be installing platypus and rebuilding the app wrapper with the python path set to /usr/local/bin/python and then symlinking python2 there.

symlink $(which python2) /usr/local/bin/python
dandavison commented 2 years ago

Thanks @jensbodal! I'm suffering from this problem now (and I'm the author...). Would you mind giving some more details about how exactly you did this part:

I was able to get around this be installing platypus and rebuilding the app wrapper with the python path set to /usr/local/bin/python

I've tried using Platypus with the path set to a valid Python interpreter, like this:

image

but I seem to still encounter the same error:

image

By the way, I don't believe it has to be a Python2 interpreter -- the open-in-editor python script works under Python2 and Python3, which I just confirmed by running it directly from the command line:

/usr/local/bin/python3 ./open-in-editor ./open-in-editor:7
dandavison commented 2 years ago

Would you be able to push your working app bundle to a fork of this repo or attach it as a file in this comment thread? I seem to be failing at using Platypus to create an app bundle that doesn't try to access /usr/bin/python.

dandavison commented 2 years ago

In my case the problem was that old versions of the OpenInEditor app were registered with the OS. In case it helps anyone else what I did was use

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump

to view the registry, and then delete the OpenInEditor entries on disk.

I'n #11 I've changed the MacOS app so that it looks for python at /usr/local/bin/python which should fix this since Apple's SIP doesn't prevent us from putting files and symlinks at that location.

eugenesvk commented 1 year ago

By the way, when I drag&drop the script in platypus, it's identified as of type env with /usr/bin/env, and I don't need to add any extra symlinks, the #!/usr/bin/env python hashbang works fine On your screenshot I see that you manually set the link to python

platy