Jump to content

Using PHP on Monterey (macOS 12)?


Recommended Posts

2 hours ago, phaistonian said:

Any idea / way on how to temp/resolve this issue until a new Alfred version comes up?


What issue?

 

2 hours ago, phaistonian said:

My main issue has to be that `/usr/bin` is read-only and so passing a symbolic link to, say, is not doable.


It’s not clear to me what you’re trying to do. Seems like there are words missing.

 

Either way, it seems like you want to create another thread. This one is informational, it does not pertain to a bug.

Link to comment

Sorry, I posted this in a rush.

 

This  (the one in attachment) is the issue I am facing on OSX 12.

 

This is because, in this scenario, php is removed from the OSX.

 

The problem is that I can not `ln -s` php binary to "/usr/bin" because the volume is "read-only" (as of Catalina, I think).

 

So, to recap, the issue, when it comes to Alfred, is that we can not change the path of php (or whatever else is missing) to custom one.

 

I hope this brouht some clarity 🙂

 

1210524578_CleanShot2021-06-30at12_29.58@2x.thumb.png.7ce9ec277d4890db2b8a759a30a3a2e3.png

 

115518938_CleanShot2021-06-30at12_28.00@2x.thumb.png.0d1bbe714d27ec59cfe7f989a49c2a39.png

Link to comment
1 hour ago, phaistonian said:

So, to recap, the issue, when it comes to Alfred, is that we can not change the path of php (or whatever else is missing) to custom one.

 

Use Language = /bin/bash and call your script with the appropriate path:

 

/usr/local/bin/php WorkflowScript.php "$1"

 

Or put a shebang in your script, make it executable, then run it as an External Script.

Link to comment
4 hours ago, Mr Pennyworth said:

This should be filed as a bug, right?

 

Maybe not this specifically, but the disappearance of /usr/bin/php is worth addressing. A huge number of workflows use it, and it would be useful if Alfred could make anything specifying /usr/bin/php transparently run with a Homebrew PHP instead.

 

Going forward, this is going to be a huge pain, as Homebrew uses a different prefix on Apple silicon, AFAIK.

Link to comment

My solution will likely be to make the default scripting language paths globally configurable, so you change it in one place to "fix" it for all workflows. I may also try to make this a bit intelligent to discover paths.

 

I'll be sure to get this done long before macOS 12 is released, but I'm currently full tilt on 4.5, so it may have to wait a little.

Link to comment
18 hours ago, Andrew said:

I may also try to make this a bit intelligent to discover paths.

 

There are only a couple of possible locations (for Homebrew PHP). Compatibility is the bigger worry, imo…

 

18 hours ago, Andrew said:

long before macOS 12 is released

 

Might be time to add /usr/bin/python3: that's been there since Catalina (although the command-line tools are needed to install it properly), and Python 2 (/usr/bin/python) is EOL.

Link to comment
  • 1 month later...

Any updates on this issue? Most of my workflows are broken because /usr/bin/php is not available anymore on macOS 12. This makes Alfred a pain to use, sometimes I invoke a workflow and get the alert instead, and to get rid of it I need at least 5 steps (1. open alfred again, 2. close duplicated alert that opens, 3. remove offending workflow call, 4. close new alert again, 5. cry in a dark room)

 

1491235038_CleanShot2021-08-12at11_06.59@2x.thumb.png.aa954f24897e817bbe836d4f18f719ce.png

 

Can you make /usr/local/bin/php available in the dropdown please? Or maybe just fallback to it if /usr/bin/php is not found, instead of throwing an alert. Seems to be the default location for any new installations through brew etc.

Edited by edjr
Link to comment

FWIW I just searched for php in my workflows folder, and I came up with about 5 that I had disabled several years ago & which I deleted, and only one active one, the Units workflow ( 

 ) which seems to just be using PHP to launch curl.  

 

Maybe we could come up with a list of workflows that are still in use with PHP?  I'm not sure there are that many.

Link to comment
  • 2 weeks later...

Biggest issue I have right now with any older workflows that reference PHP is once it's loaded and the error dialogue appears I have to force quit Alfred to be able to search again. Otherwise Alfred get stuck in a loop where the last workflow search loads and the error appears and blocks the app.

Link to comment
6 hours ago, Neilio said:

Biggest issue I have right now with any older workflows that reference PHP is once it's loaded and the error dialogue appears I have to force quit Alfred to be able to search again. Otherwise Alfred get stuck in a loop where the last workflow search loads and the error appears and blocks the app.

 

You should definitely file a bug report for that. https://www.alfredforum.com/forum/6-bug-reports/

 

Link to comment
8 hours ago, Neilio said:

Biggest issue I have right now with any older workflows that reference PHP is once it's loaded and the error dialogue appears I have to force quit Alfred to be able to search again. Otherwise Alfred get stuck in a loop where the last workflow search loads and the error appears and blocks the app.

 

Hmm - this is happening because you likely have the option to show the latest query again:

 

Screenshot 2021-08-27 at 12.17.03.png

 

... which is automatically running the workflow again when you re-show Alfred.

 

The popup you see was never really intended to be seen unless there was a really bad issue, and now that php is missing, this "really bad issue" is actually happening. I am in the process of working through the best solution to this which should also prevent you from getting blocked by this dialog.

Link to comment

Just as a quick update on this, when I release the next version, the bin error dialog now gives a few more useful options allowing for workflow to be opened or disabled so you don't see the issue again:

 

Screenshot 2021-09-02 at 16.47.07.png

Alfred will also search for alternative paths when the macOS standard bin path is missing, e.g. for php Alfred will also look in:

 

/opt/homebrew/bin/php
/usr/local/bin/php

 

I have some more changes I want to implement for the next release, however, there is a good chance I'll do an interim build in the next few days which will contain this change, allowing for macOS 12 users to use php workflows if they have an alternative php installed (e.g. via homebrew).

 

Cheers,

Andrew

Link to comment

@dfay for now, the logic is quite simple in that if the bin is missing from the original location (i.e. php is no longer installed by macOS in /usr/bin/php), it will look in those 2 alternative locations. It does this for all the selectable languages in Alfred's Run Script for future proofing.

 

If you want to use an arbitrary language, I recommend using the "External Script" option.

Link to comment
On 9/12/2021 at 4:51 PM, Andrew said:

If you want to use an arbitrary language

 

It's not arbitrary: Python 3 is part of Apple's devtools. Python 2 is still part of the OS, but it's EOL and should not be used if possible.

 

/usr/bin/python should be marked as deprecated, imo. It's now dead and shouldn’t really be used for any new workflows.

 

On 9/9/2021 at 6:41 PM, dfay said:

would this also work for python 3?

 

Only for workflows written for Python 3, which Alfred has never had official support for.

 

Python 3 is sufficiently different that most non-trivial programs written for Python 2 won't run unchanged.

 

Link to comment
  • 1 month later...

I have php installed via Homebrew, and I'm on Alfred 4.6 on Monterey, but workflows using php are breaking.

 

Confirming that php works in the command line on my machine:

% which php
/usr/local/bin/php
% php -r 'echo function_exists("foo") ? "yes" : "no";'
no%

 

According to this blog post, "If you install PHP (e.g. via homebrew), most PHP-based workflows will continue to work without an issue, as the workflow script objects in Alfred 4.6 have been updated to be aware of alternative bin paths."

 

But in a bare-bones Alfred workflow with language set to bin/bash:

 

php -r 'echo function_exists("foo") ? "yes" : "no";'

 

gets me "line 1: php: command not found" in the debugger.

 

Am I misunderstanding something?

Link to comment
1 hour ago, paulw said:

According to this blog post, "If you install PHP (e.g. via homebrew), most PHP-based

 

Key word there being most, because not all cases can be covered. Mainly:

 

1 hour ago, paulw said:

in a bare-bones Alfred workflow with language set to bin/bash

 

Alfred doesn’t (and shouldn’t) edit the script’s contents, so if php is literally written on it the issue still manifests. But you (or the author) can edit the script. Add to it, at the top, the line export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}" and it should work.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...