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

$PATH is changed during patch execution #38

Open
kenjis opened this issue Jan 21, 2024 · 5 comments
Open

$PATH is changed during patch execution #38

kenjis opened this issue Jan 21, 2024 · 5 comments

Comments

@kenjis
Copy link
Contributor

kenjis commented Jan 21, 2024

This may be an issue on macOS, $PATH is changed in src/patch.
So it may change the php binary version, and may install unexpected versions of the packages.

In my case, I have both /usr/local/opt/php@8.2/bin/php (8.2) and /usr/local/bin/php (8.3).
I expect that PHP 8.2 is used, but patch uses PHP 8.3.

  • OS: macOS 12.7.2
  • Shell: bash
$ vendor/bin/patch
bin/patch
/usr/local/opt/mysql@5.6/bin:/usr/local/opt/curl/bin:/usr/local/opt/openldap/sbin:/usr/local/opt/openldap/bin:/usr/local/opt/openssl@1.1/bin:/usr/local/opt/php@8.2/sbin:/usr/local/opt/php@8.2/bin:./vendor/bin:/Users/kenji/.composer/vendor/bin:/Users/kenji/.nodebrew/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/kenji/bin

src/patch
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/opt/mysql@5.6/bin:/usr/local/opt/curl/bin:/usr/local/opt/openldap/sbin:/usr/local/opt/openldap/bin:/usr/local/opt/openssl@1.1/bin:/usr/local/opt/php@8.2/sbin:/usr/local/opt/php@8.2/bin:./vendor/bin:/Users/kenji/.composer/vendor/bin:/Users/kenji/.nodebrew/current/bin:/Users/kenji/bin
--- vendor/bin/patch.bk	2023-09-29 13:02:52.000000000 +0900
+++ vendor/bin/patch	2024-01-21 13:37:11.000000000 +0900
@@ -1,5 +1,9 @@
 #!/usr/bin/env sh
 
+echo "bin/patch"
+echo $PATH
+echo
+
 # Support bash to support `source` with fallback on $0 if this does not run with bash
 # https://stackoverflow.com/a/35006505/6512
 selfArg="$BASH_SOURCE"
--- vendor/tatter/patches/src/patch.bk	2023-09-26 21:23:22.000000000 +0900
+++ vendor/tatter/patches/src/patch	2024-01-21 13:37:04.000000000 +0900
@@ -1,5 +1,9 @@
 #!/bin/sh -l
 
+echo "src/patch"
+echo $PATH
+exit
+
 ##
 # Tatter\Patches
 # https://github.com/tattersoftware/codeigniter4-patches
@whoisninjaturtle
Copy link
Contributor

Interesting. I took a quick look at this in the same way on a RH-flavor Linux install and my PATHs are not rearranged like you're describing.

bin/patch
/root/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/bin/remote-cli:/root/.nvm/versions/node/v13.12.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

src/patch
/root/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/bin/remote-cli:/root/.nvm/versions/node/v13.12.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Unfortunately I don't have a Mac to look into this further on that end.

@MGatner
Copy link
Contributor

MGatner commented Feb 8, 2024

Hmm it's probably the Login directive:

#!/bin/sh -l

Maybe it doesn't play well with Composer's script wrapping?

@whoisninjaturtle
Copy link
Contributor

whoisninjaturtle commented Feb 8, 2024

I noticed that change and wondered myself too. I did look closely at the two given PATHs and they are simply just rearranged, not actually different in content, which makes me think it's a sourcing order issue

@kenjis
Copy link
Contributor Author

kenjis commented Feb 8, 2024

I guess macOS does something.

@whoisninjaturtle
Copy link
Contributor

More to your original point, it would seem advantageous in multi-version environments to be able to pass the desired PHP executable path into patch via CLI option

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

3 participants