Git WebHook (PHP) cannot access ruby ​​environment by running jekyll as apache user

I have a post-merge hook in my git repository that just runs the jekyll command.

When I run git pull , post-merge works without problems.

However, I have a PHP file that will act as a WebHook for the remote:

 $pull = `cd .. && git pull`; echo $pull; 

When I access this file, git pulls works ( after some initial problems ) and succeeds. However, for some reason post-merge fails. If I look inside my Apache error_log , I find the following error:

.git/hooks/post-merge: line 5: jekyll: command not found

This is odd, given that post-merge runs jekyll successfully when I do the git pull manual via SSH.

If I use the full path to the executable, as suggested here , I get this error in my error_log :

/usr/bin/env: ruby_noexec_wrapper: No such file or directory

I installed Ruby through RVM.

How can I run jekyll apache without problems?

Edit: Here is my current post-merge :

 #!/bin/sh unset GIT_DIR source /usr/local/rvm/environments/ruby-1.9.3-p194 /usr/local/rvm/gems/ruby-1.9.3-p194/bin/jekyll echo "Deployed!" 

When I run this as an apache user, now I get this error:

Node.js.

+7
source share
3 answers

Since I used RVM, I had to specify that instead of Ruby directly. Not sure why, but now it works.

My post-merge looks something like this:

 #!/bin/bash unset GIT_DIR /usr/local/rvm/bin/rvm use 1.9.3 /usr/local/rvm/gems/ruby-1.9.3-p194/bin/jekyll echo "Deployed!" 

Not perfect - rvm echoes things I don’t want, but it works.

+2
source

I think this error is very clear:

 jekyll: command not found 

you must use the full path to your jekyll .

 whereis jekyll 

then run the command with the full path, for example:

 /usr/local/bin/jekyll --params 

Here is a solution to the ruby_noexec_wrapper problem.

stack overflow

Edit:

 Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available 

ExecJS and could not find JavaScript runtime

+4
source

I fixed this problem by adding the following to my ~/.bash_profile file:

 source ~/.bashrc 

The rvm installer should already add

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* 

I added the source line above this and fixed these problems.

0
source

All Articles