alfred-homebrew icon indicating copy to clipboard operation
alfred-homebrew copied to clipboard

Not working in Monterey 12.3

Open ismaelab opened this issue 3 years ago • 12 comments

Since I have updated to Monterey, I can't get the workflow to work anymore.

This is the error I receive:

Homebrew & Cask for Alfred[[Script Filter] Queuing argument '' Homebrew & Cask for Alfred[[Script Filter] Script with argv '(null)' finished ERROR: Homebrew & Cask for Alfred[[Script Filter]Code 127: /bin/bash: python: command not found

ismaelab avatar Mar 16 '22 06:03 ismaelab

Hi @ismaelab, I'm afraid I can't look into this as I haven't upgraded to Monterey yet. Contributions are more than welcome!

fniephaus avatar Mar 18 '22 16:03 fniephaus

Python2 was uninstalled in 12.3 Try reinstalling python2.

Reference: https://www.alfredapp.com/help/kb/python-2-monterey/

Daeho-Son avatar Mar 19 '22 06:03 Daeho-Son

Python2 was uninstalled in 12.3 Try reinstalling python2.

Reference: https://www.alfredapp.com/help/kb/python-2-monterey/

Didn't solve the issue for me unfortunately.

HenryQW avatar Mar 20 '22 15:03 HenryQW

I was able to get the workflow running with a workaround hope this helps

I am basically replacing the python command with the complete location of the python command since I am unable to get the python command working globally on mac

  1. Installing python 2 as suggested by @Sondho
  2. Go to the homebrew workflow and enable debug mode.
  3. Trigger the brew keyword in Alfred.
  4. If you are getting Code 127: /bin/bash: python: command not found error.
  5. Open the script filter for brew and cask and change the script as follows
  6. From python brew.py "{query}" to /Users/<your username>/.pyenv/shims/python brew.py "{query}"
  7. Repeat for cask script filter
  8. Trigger the brew or cask keyword in Alfred again
  9. If you get background.py:234 no file found error
  10. Open the background.py file from the location shown in the error
  11. Go to line 233 and replace python with /Users/<your username>/.pyenv/shims/python

hdecoded avatar Apr 09 '22 04:04 hdecoded

Great job tracking down a solution. Followed the steps and can confirm that it is working on 12.3.1 I did have one small issue that was easily resolved. pyenv wasn't satisfied until I explicitly specified my python version.

For some reason it defaulted to 'system' on my machine.

I fixed it with pyenv global 2.7.18

cryophobic avatar Apr 13 '22 03:04 cryophobic

@cryophobic Gald I helped.

hdecoded avatar Apr 16 '22 05:04 hdecoded

Avoiding screenshots might be a start

💻😉 (sorry, the opportunity was too good)

pat-s avatar Jun 10 '22 08:06 pat-s

Is there anything in https://github.com/fniephaus/alfred-homebrew/issues/52#issuecomment-1093658852 we can integrate into the workflow so that it's easier to set up Python 2 with pyenv or homebrew?

fniephaus avatar Jun 24 '22 13:06 fniephaus

I don't know much about developing Alfred workflows, and even less about Python, so maybe this is a terrible idea, but...

Python3 executable is only 167kb, so I assume Python 2 is roughly the same size. Could you not package the exact version of python you need into the plugin itself and reference it directly? This would avoid the entire process of dealing with pyenv, shims, $PATH, system updates, etc.

The only hangup I would expect to see is MacOS Gatekeeper preventing the packaged python executable from running initially. But that seems like a far easier task to guide users around than installing pyenv.

Thoughts?

skoskie avatar Jun 24 '22 17:06 skoskie

Please switch to python3, python2 is EOL and a security risk.

Bundling a language interpreter into an application is quite unusual and comes with more challenges than keeping just the executable size small.

pat-s avatar Jun 24 '22 18:06 pat-s

I was able to get the workflow running with a workaround hope this helps

I am basically replacing the python command with the complete location of the python command since I am unable to get the python command working globally on mac

  1. Installing python 2 as suggested by @Sondho
  2. Go to the homebrew workflow and enable debug mode.
  3. Trigger the brew keyword in Alfred.
  4. If you are getting Code 127: /bin/bash: python: command not found error.
  5. Open the script filter for brew and cask and change the script as follows
  6. From python brew.py "{query}" to /Users/<your username>/.pyenv/shims/python brew.py "{query}"
  7. Repeat for cask script filter
  8. Trigger the brew or cask keyword in Alfred again
  9. If you get background.py:234 no file found error
  10. Open the background.py file from the location shown in the error
  11. Go to line 233 and replace python with /Users/<your username>/.pyenv/shims/python

I tried this solution under python 3.9 but failed. In the beginning, I can go through to step 8, but still did not solve. It did not hint step 9 ever. Even if I installed python 2.7.18, the debug shows "[Errno 2] No such file or directory". Any help would be appreciated in advance. Thx

Yinsen-P avatar Jul 16 '22 20:07 Yinsen-P

I'm getting an error that the module cPickle is not found. In looking at the python code for the workflow.py file, there is a reference to cPickle. In the workflow3.py file there is no reference cPickle. This note is at the top of the workflow.py file, but I'm not sure which user manual I'm supposed to refer to: """The :class:Workflow object is the main interface to this library.

:class:Workflow is targeted at Alfred 2. Use :class:~workflow.Workflow3 if you want to use Alfred 3's new features, such as :ref:workflow variables <workflow-variables> or more powerful modifiers.

See :ref:setup in the :ref:user-manual for an example of how to set up your Python script to best utilise the :class:Workflow object.

Can someone point me to the right material?

mdking117 avatar Jul 21 '22 23:07 mdking117

Regarding Line 9: "background.py:234 no file found error"

One can completely disable run_in_background because there is no point of updating the workflow (actually should not run autoupdate) if it's unmaintained and users need to make a local patch to make this workflow with damn python 2.

     # Call this script
     cmd = ['/usr/bin/python', __file__, name]
     _log().debug('[%s] passing job to background runner: %r', name, cmd)

-    retcode = subprocess.call(cmd)
+    retcode = -1

     if retcode:  # pragma: no cover
         _log().error('[%s] background runner failed with %d', name, retcode)
     else:
         _log().debug('[%s] background job started', name)

wookayin avatar Nov 17 '22 02:11 wookayin

Adding to the solution from @hdecoded (which worked out great, thank you!) Specifying python 2 for the scripts of that workflow alone might save one from having to set them as the global python version (assuming you're using pyenv):

/Users/<>/.pyenv/shims/python2

marcelluiz96 avatar Feb 15 '23 08:02 marcelluiz96