Question

Automatic deploy with Git fails on deploy

  • Posted on August 17, 2014
  • pzinAsked by pzin

Hi,

I followed this article to deploy a RoR app automatically when I push my changes to the server. I think everything works fine, except on the part of the deployment.

I just do some simple mostly needed commands in a RoR deployment; bundle and rake tasks.

My (taking the example from the tutorial) /var/repo/site.git/hooks/post-receive looks like this:

#!/bin/bash
export PATH=$PATH:/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby
export RAILS_ENV="production"
git --work-tree=/home/rails --git-dir=/home/repo/blog.git checkout -f
cd /home/rails
bundle install
rake db:migrate
rake assets:precompile        
chown -R rails:www-data /home/rails
service unicorn restart

I get three errors, from bundle to the assets precompile:

remote: hooks/post-receive: /usr/local/bin/bundle: /usr/bin/ruby1.8: bad interpreter: No such file or directory
remote: hooks/post-receive: /usr/local/bin/rake: /usr/bin/ruby1.8: bad interpreter: No such file or directory
remote: hooks/post-receive: /usr/local/bin/rake: /usr/bin/ruby1.8: bad interpreter: No such file or directory

If I run those commands or the complete file from the server directly, it works fine, but not if I run it remotely (deploying with Git). I cannot understand why. Strange thing also that Ruby 1.8 appears there. Checking RVM there’s just one version of Ruby installed, which is Ruby 2.0.0.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This is most like due to the fact that:

export PATH=$PATH:/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby
export RAILS_ENV="production"

Isn’t actually modifying the PATH You’ll need to do something like creating a separate script that only exports the new PATH Then in the post-receive script run:

source scriptname.sh