0

I'm deploying a Ruby on Rails / NodeJS application to a dedicated host using git's post-receive hook.

git checkout -f
/site/sys/post-receive.sh

My repository is in one folder, repo.git and the actual files are copied to site.

The problem is that RVM isn't in my path (I guess), so: bundle install fails with bundle no such command.

What should I do?

Full bundle error:

remote: /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
remote:     from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
remote:     from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1230:in `gem'
remote:     from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/bundle:18:in `<main>'
CamelCamelCamel
  • 5,200
  • 8
  • 61
  • 93
  • Maybe this (much cleaner) solution works for you: http://stackoverflow.com/a/23898362/2167061 – Alex Dec 04 '14 at 22:26

1 Answers1

1

Type which bundle to see the exact location of the executable. And then use that absolute location in the post receive hook script.

ErJab
  • 6,056
  • 10
  • 42
  • 54
  • "Could not find bundler (>= 0) amongst..." - I've tried this before (and again now). `bundle` does work in direct ssh. – CamelCamelCamel May 06 '12 at 22:39
  • "bundle does work in direct ssh". I'm not sure if you understood my answer, so here goes: Login to SSH, and type `which bundle`. It will return the path to the bundle executable. Now use that path in the post-receive hook script. – ErJab May 06 '12 at 22:52
  • I did :-) when I ssh bundle works correctly. When I use the path inside the post receive it doesn't work and displays the error above. The path: `/usr/local/rvm/gems/ruby-1.9.3-p125/bin/bundle` and the error: `Could not find bundler (>= 0) amongst...` – CamelCamelCamel May 06 '12 at 22:55
  • Oh ok! Could you paste the full error: `Could not find bundler (>= 0) amongst...` What does it should after the ellipsis? – ErJab May 06 '12 at 22:58
  • I'm not a Rails expert (yet!), but I'm a sysadmin. So I thought I could help just by looking at the error you posted! But it looks your issue requires some knowledge about Rails installation. Have a look at this question: http://stackoverflow.com/questions/6166081/could-not-find-bundler-error – ErJab May 06 '12 at 23:26
  • Thank you non the less! I suspect it has something to do with the atrocious rvm, yeah. – CamelCamelCamel May 06 '12 at 23:33