Switched to Git and now server can't find Rubygems

18 views
Skip to first unread message

rko618

unread,
Jun 24, 2008, 8:52:43 PM6/24/08
to Capistrano
We am in the process of switching our site to Git from SVN. The
deployment was working fine with SVN and Capistrano 2.2. After
switching the deployment settings over to git and upgrading to
Capistrano 2.4 I am getting the following error when I run `cap
deploy:migrations`.

* executing "cd /var/www/mysite.com/releases/20080624225409; rake
RAILS_ENV=production db:migrate"
servers: ["mysite.com"]
[mysite.com] executing command
** [out :: mysite.com] /usr/local/rubygems/gems/bin/rake:9:in
`require'
** [out :: mysite.com] :
** [out :: mysite.com] no such file to load -- rubygems
** [out :: mysite.com] (
** [out :: mysite.com] LoadError
** [out :: mysite.com] )
** [out :: mysite.com] from /usr/local/rubygems/gems/bin/rake:9
command finished
command "cd /var/www/mysite.com/releases/20080624225409; rake
RAILS_ENV=production db:migrate" failed on mysite.com


This is my deploy.rb has:

# config/deploy.rb
default_run_options[:pty] = true

set :application, "mysite"
set :repository, "g...@github.com:mysite.git"
set :user, "deploy"
set :password, "xxxxx"

set :scm, :git
set :scm_passphrase, "xxxxx"
set :git_enable_submodules, true
set :deploy_via, :remote_cache
set :branch, "master"

set :deploy_to, "/var/www/mysite.com/"
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
set :runner, "deploy"
set :rails_env, "production"

set :domain, "mysite.com"
role :web, domain
role :app, domain
role :db, domain, :primary => true

set :rake_cmd, (ENV['RAKE_CMD'] || nil)


Obviously the first thing I did was check my path to see if it
included the gem command and it does:
/usr/local/rubygems/gems/bin:/usr/local/rubygems/bin:/usr/local/bin:/
usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/deploy/bin

I'm really confused why this is not working. When I redeploy using svn
repo it runs fine which is even more perplexing.

rko618

unread,
Jun 25, 2008, 6:05:49 PM6/25/08
to Capistrano
After several hours I finally discovered a fix. Defining RUBYLIB AND
GEM_HOME in .ssh/environment did the trick.

I'm still very curious as to why this worked perfectly with subversion
but does not work with Git? What is it about using git that caused
capistrano to need those variables to be defined?

Jamis Buck

unread,
Jun 25, 2008, 6:14:33 PM6/25/08
to capis...@googlegroups.com
I suspect the change to git was a red herring. There is nothing about
git or capistrano that relies on those variables on the remote hosts.

- Jamis

jywa...@gmail.com

unread,
Aug 11, 2008, 3:40:46 PM8/11/08
to Capistrano
~/.bash_profile does not persist over interactive sessions. Here they
recommend putting it into ~/.bashrc, which did not work for me:

http://railsforum.com/viewtopic.php?id=1857

After putting these lines into my ~/.bashrc :

export PATH=$PATH:/home/30948/data/rubygems/bin:/home/30948/data/
rubygems/gems/bin
export RUBYLIB=/home/30948/data/rubygems/local/lib/site_ruby/1.8:/home/
30948/data/rubygems/lib
export GEM_HOME=/home/30948/data/rubygems/gems
export GEM_PATH=/home/30948/data/rubygems/gems

I did cap shell, then:

cap> env

yielded:

...
** [out :: xxxxx.net] GEM_HOME=/home/xxxxx/data/rubygems/gems
** [out :: xxxxx.net] SHELL=/bin/bash
** [out :: xxxxx.net] TERM=xterm
** [out :: xxxxx.net] SSH_CLIENT=xxx.xxx.xxx.xxx 44288 22
** [out :: xxxxx.net] SSH_TTY=/dev/pts/23
** [out :: xxxxx.net] USER=xxxxx.net
** [out :: xxxxx.net] PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/
usr/games:/home/xxxxx/data/rubygems/bin:/home/xxxxx/data/rubygems/gems/
bin:/home/xxxxx/data/rubygems/bin:/home/xxxxx/data/rubygems/gems/bin
** [out :: xxxxx.net] MAIL=/var/mail/xxxxx.net
** [out :: xxxxx.net] _=/usr/bin/env
** [out :: xxxxx.net] PWD=/nfs/c02/h03/mnt/xxxxx/users/.home
** [out :: xxxxx.net] HOME=/home/xxxxx/users/.home
** [out :: xxxxx.net] SHLVL=2
** [out :: xxxxx.net] LOGNAME=xxxxx.net
** [out :: xxxxx.net] SSH_CONNECTION=xxx.xxx.xxx.xxx 44288
xxx.xxx.xxx.xxx 22
** [out :: xxxxx.net] RUBYLIB=/home/xxxxx/data/rubygems/local/lib/
site_ruby/1.8:/home/xxxxx/data/rubygems/lib
...

How odd. I'm probably missing something obvious here...

Jeff

Jamis Buck

unread,
Aug 11, 2008, 4:07:47 PM8/11/08
to capis...@googlegroups.com
If you have the fo

Jamis Buck

unread,
Aug 11, 2008, 4:09:53 PM8/11/08
to capis...@googlegroups.com
Do you have the following in your deploy.rb anywhere?

default_run_options[:pty] = true

If so, then yeah, even .bashrc won't get loaded. In that case, there
really isn't a clean solution for you. You can try something like this:

default_run_options[:env] = { "PATH" => "complete path here",
"RUBYLIB" => "rubylib here", ... }

- Jamis

On Aug 11, 2008, at 1:40 PM, je...@vestaldesign.com wrote:

Reply all
Reply to author
Forward
0 new messages