Page MenuHomePhabricator

Set php PATH for repository's hook
ClosedPublic

Authored by iodragon on Dec 8 2013, 3:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 8:55 PM
Unknown Object (File)
Sat, Apr 27, 8:54 PM
Unknown Object (File)
Sat, Apr 27, 8:54 PM
Unknown Object (File)
Sat, Apr 27, 8:54 PM
Unknown Object (File)
Sat, Apr 27, 8:54 PM
Unknown Object (File)
Sat, Apr 27, 8:54 PM
Unknown Object (File)
Wed, Apr 24, 11:15 PM
Unknown Object (File)
Wed, Apr 17, 8:44 PM

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Commits
Restricted Diffusion Commit
rPf981d50f5db6: Set php PATH for repository's hook
Summary

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.

Test Plan

check the hook generated is contain the right path

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

iodragon updated this revision to Unknown Object (????).Dec 8 2013, 3:49 PM

update env for unit test

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.

iodragon updated this revision to Unknown Object (????).Jan 3 2014, 6:28 AM

using epriestley's implement

Closed by commit rPf981d50f5db6 (authored by @iodragon, committed by @epriestley).