Set PATH for repository's hook, so the environment.append-paths can used
repository's hook may can't find php path if user's profile like bash_profile is not loaded.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- Restricted Diffusion Commit
rPf981d50f5db6: Set php PATH for repository's hook
check the hook generated is contain the right path
Diff Detail
- Branch
- master
- Lint
Lint Passed - Unit
Tests Passed
Event Timeline
What error are you running into, specifically?
Generally, this shouldn't be necessary, because we write an absolute path here and then load __init_script__.php, which will load your configured environment (including environment.append-paths).
If you have an old install which uses PHABRICATOR_ENV to select a custom config file, that won't make it, so options in your custom config file won't be loaded. The easiest fix is probably to create conf/local/ENVIRONMENT and write the environmental variable's value into that file. That will make sure your custom config file gets loaded.
(Generally, we've moved away from PHABRICATOR_ENV and stopped recommending it about a year ago, but older installs may still use it.)
Sorry, I have made some misunderstanding about this.
My problem is my php is installed in a custom path, and added to $PATH in ~/.bash_profile.
It seems the git hook does't load the bash_profile. So I try to fix it.
Hmm. I'd rather write this hook, then:
$full_php_path = Filesystem::resolveBinary('php'); $cmd = csprintf('exec %s -f %s %s "$@"', $full_php_path, $bin, $callsign);
Does that work on your system?
$bin mean it may be not a php script, I think make sure php is in PATH is better?
like this:
$php_dir = dirname(Filesystem::resolveBinary('php')); $hook = "#!/bin/sh\nPATH={$php_dir}:\$PATH\n{$cmd}\n";
$bin will always be a PHP script -- and if it's not, putting php in PATH won't help with anything and will produce a more confusing error.