3

I'm following rails Cast episode 335: http://railscasts.com/episodes/335-deploying-to-a-vps

using a linode VPN,

running:

cap deploy:cold

* executing `deploy:cold'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:benamir/listpro.git master"
    command finished in 1546ms
  * executing "if [ -d /home/deployer/apps/listpro/shared/cached-copy ]; then cd /home/deployer/apps/listpro/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 84770c5b6f38dbfeca1b5ef619fb1b9940121a4e && git clean -q -d -x -f; else git clone -q git@github.com:benamir/listpro.git /home/deployer/apps/listpro/shared/cached-copy && cd /home/deployer/apps/listpro/shared/cached-copy && git checkout -q -b deploy 84770c5b6f38dbfeca1b5ef619fb1b9940121a4e; fi"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 2874ms
    copying the cached version to /home/deployer/apps/listpro/releases/20121012050310
  * executing "cp -RPp /home/deployer/apps/listpro/shared/cached-copy /home/deployer/apps/listpro/releases/20121012050310 && (echo 84770c5b6f38dbfeca1b5ef619fb1b9940121a4e > /home/deployer/apps/listpro/releases/20121012050310/REVISION)"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 8648ms
  * executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * executing `deploy:assets:symlink'
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/public/assets &&\\\n        mkdir -p /home/deployer/apps/listpro/releases/20121012050310/public &&\\\n        mkdir -p /home/deployer/apps/listpro/shared/assets &&\\\n        ln -s /home/deployer/apps/listpro/shared/assets /home/deployer/apps/listpro/releases/20121012050310/public/assets"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 246ms
  * executing "chmod -R g+w /home/deployer/apps/listpro/releases/20121012050310"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 878ms
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/public/system && mkdir -p /home/deployer/apps/listpro/releases/20121012050310/public/"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 99ms
  * executing "ln -s /home/deployer/apps/listpro/shared/system /home/deployer/apps/listpro/releases/20121012050310/public/system"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 96ms
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/log"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 95ms
  * executing "ln -s /home/deployer/apps/listpro/shared/log /home/deployer/apps/listpro/releases/20121012050310/log"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 95ms
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/tmp/pids && mkdir -p /home/deployer/apps/listpro/releases/20121012050310/tmp/"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 99ms
  * executing "ln -s /home/deployer/apps/listpro/shared/pids /home/deployer/apps/listpro/releases/20121012050310/tmp/pids"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 95ms
    triggering after callbacks for `deploy:finalize_update'
  * executing `bundle:install'
  * executing "ls -x /home/deployer/apps/listpro/releases"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 132ms
  * executing "cd /home/deployer/apps/listpro/releases/20121012050310 && bundle install --gemfile /home/deployer/apps/listpro/releases/20121012050310/Gemfile --path /home/deployer/apps/listpro/shared/bundle --deployment --quiet --without development test"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
 ** [out :: 198.74.59.184] sh: bundle: not found
    command finished in 95ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310; true"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 868ms
failed: "sh -c 'cd /home/deployer/apps/listpro/releases/20121012050310 && bundle install --gemfile /home/deployer/apps/listpro/releases/20121012050310/Gemfile --path /home/deployer/apps/listpro/shared/bundle --deployment --quiet --without development test'" on 198.74.59.184
[listpro-a(__git_ps1 " (%s)")]$ 

I apologize, we must backtrack...

after running rbenv installer:

 curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash

I get

 Seems you still have not added 'rbenv' to the load path:

export RBENV_ROOT="${HOME}/.rbenv"

if [ -d "${RBENV_ROOT}" ]; then
   export PATH="${RBENV_ROOT}/bin:${PATH}"
   eval "$(rbenv init -)"
fi

The above is already saved in my .bashrc file

Yesterday: executing all these commands worked: rbenv bootstrap-ubuntu-10-04 rbenv install 1.9.3-p125 rbenv global 1.9.3-p125 gem install bundler --no-ri --no-rdoc rbenv rehash

but after cap deploy, rbenv is no longer in my path.

  rbenv: command not found

echo $PATH:

 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Szymon Jeż
  • 8,273
  • 4
  • 42
  • 60
Benamir
  • 1,107
  • 2
  • 11
  • 24
  • Please paste more of the log output you got while running `cap deploy:cold`. There should be more information than you provided. – Szymon Jeż Oct 12 '12 at 12:28
  • Added @jeznet. Also note below, When I do bundle install in my ~/apps/listpro/releases$ OR ~/apps/listpro/$ directory I get: -bash: bundle: command not found – Benamir Oct 12 '12 at 12:46
  • I added some more info @Jeznet, perhaps it will help. – Benamir Oct 12 '12 at 13:32
  • Capistrano should not break rbenv. Please provide the information how you execute the commands you posted above. You run them via capistrano (i.e. cap shell) or directly in the os shell (after ssh)? – Szymon Jeż Oct 12 '12 at 14:25
  • I run the curl command above directly in the os shell after ssh. should I be in the cap shell? – Benamir Oct 12 '12 at 14:49
  • I meant the rbmnv command. Try to ssha and: `rbenv -v`. First fix rbenv (install it again etc.) then you must tell capistrano how to reuse rbenv. I do not know anything about rbenv. So wothout looking in the manual for it I cant help you. Good luck. – Szymon Jeż Oct 12 '12 at 14:52

3 Answers3

4

The thing is that when capistrano runs, it doesn't load the .profile, so you need to load rbenv manually.

Add this to your deploy.rb file:

set :default_environment, {
  'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}

That should be enough.

Note: I'm using Ubuntu Precise Pangolin on my server.

Juanda
  • 1,648
  • 1
  • 20
  • 29
  • This certainly solved it for me - couldn't work out why commands would work if I SSH'ed in, but not via cap. Thanks! – theTRON Apr 22 '13 at 07:33
0

login to your server, cd to latest release and try to bundle install see what error it gives

Rubyman
  • 874
  • 6
  • 15
  • When I do bundle install in my ~/apps/listpro/releases$ OR ~/apps/listpro/$ directory I get: -bash: bundle: command not found – Benamir Oct 12 '12 at 12:46
0

Bacause of:

  * executing "cd /home/deployer/apps/listpro/releases/20121012050310 && bundle install --gemfile /home/deployer/apps/listpro/releases/20121012050310/Gemfile --path /home/deployer/apps/listpro/shared/bundle --deployment --quiet --without development test"
servers: ["198.74.59.184"]
[198.74.59.184] executing command
** [out :: 198.74.59.184] sh: bundle: not found

It appears that you do not have bundler installed. Try to ssh and execute:

gem install bundler

Maybe this will help. If not provide more information and I might help you with it.

Szymon Jeż
  • 8,273
  • 4
  • 42
  • 60
  • -bash: gem: command not found ... i've followed the railscast episode and have pretty much the same deployment code. Except where you see "blog" in his I have "listpro". I also have a more extensive .gitignore file... not sure if there would be something in there causing this issue. – Benamir Oct 12 '12 at 13:06
  • It looks like you do not have Ruby installed (at least not rubygems) or you have them but you do not have them in your PATH. Try `ruby -v` to check if you have Ruby. If not install it also with rubygems. – Szymon Jeż Oct 12 '12 at 13:19
  • ya ruby -v does not work, but it was working yesterday... rbenv does not even work. it appears to not be in my PATH – Benamir Oct 12 '12 at 13:24