I’m just starting to use git-deploy instead of capistrano, the problem is though that I’m using rvm on my server and the two are not mixing well.
Here is a link to the git-deploy which I’m using:
https://github.com/mislav/git-deploy
I’m using ruby 1.9.2-p180 on my server installed through rvm for the user. When I run my git push and git deploy runs my scripts in the deploy it installs the gems in vendor/.bundle instead of my gems directory: /home/vps/.rvm/gems
Here is my deploy/after_push script
#!/usr/bin/env bash
set -e
oldrev=$1
newrev=$2
run() {
[ -x $1 ] && $1 $oldrev $newrev
}
echo files changed: $(git diff $oldrev $newrev --diff-filter=ACDMR --name-only | wc -l)
umask 002
git submodule init && git submodule sync && git submodule update
export GEM_HOME=/home/vps/.rvm/gems/ruby-1.9.2-p180
export MY_RUBY_HOME=/home/vps/.rvm/rubies/ruby-1.9.2-p180
export GEM_PATH=/home/vps/.rvm/gems/ruby-1.9.2-p180:/home/vps/.rvm/gems/ruby-1.9.2-p180@global
export RUBY_VERSION=ruby-1.9.2-p180
export PATH=/home/vps/.rvm/gems/ruby-1.9.2-p180/bin:/home/vps/.rvm/gems/ruby-1.9.2-p180@global/bin:/home/vps/.rvm/rubies/ruby-1.9.2-p180/bin:/home/vps/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export rvm_config_path=/home/vps/.rvm/config
export rvm_path=/home/vps/.rvm
export rvm_examples_path=/home/vps/.rvm/examples
export rvm_rubies_path=/home/vps/.rvm/rubies
export rvm_usr_path=/home/vps/.rvm/usr
export rvm_src_path=/home/vps/.rvm/src
export rvm_version=1.6.3
export rvm_gems_path=/home/vps/.rvm/gems
export rvm_ruby_string=ruby-1.9.2-p180
export rvm_tmp_path=/home/vps/.rvm/tmp
export rvm_lib_path=/home/vps/.rvm/lib
export rvm_repos_path=/home/vps/.rvm/repos
export rvm_log_path=/home/vps/.rvm/log
export rvm_help_path=/home/vps/.rvm/help
export rvm_environments_path=/home/vps/.rvm/environments
export rvm_archives_path=/home/vps/.rvm/archives
rvm use 1.9.2
run deploy/before_restart
run deploy/restart && run deploy/after_restart
Here is my deploy/before_restart
#!/home/vps/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
oldrev, newrev = ARGV
def run(cmd)
exit($?.exitstatus) unless system "umask 002 && #{cmd}"
end
RAILS_ENV = ENV['RAILS_ENV'] || 'production'
use_bundler = File.file? 'Gemfile'
rake_cmd = use_bundler ? 'bundle exec rake' : 'rake'
if use_bundler
bundler_args = ['--deployment']
BUNDLE_WITHOUT = ENV['BUNDLE_WITHOUT'] || 'development:test'
bundler_args << '--without' << BUNDLE_WITHOUT unless BUNDLE_WITHOUT.empty?
# update gem bundle
run "bundle install #{bundler_args.join(' ')}"
end
if File.file? 'Rakefile'
num_migrations = `git diff #{oldrev} #{newrev} --diff-filter=A --name-only`.split("\n").size
# run migrations if new ones have been added
run "#{rake_cmd} db:migrate RAILS_ENV=#{RAILS_ENV}" if num_migrations > 0
end
# clear cached assets (unversioned/ignored files)
run "git clean -x -f -- public/stylesheets public/javascripts"
# clean unversioned files from vendor/plugins (e.g. old submodules)
run "git clean -d -f -- vendor/plugins"
Not only does it install it in vendor/.bundle but it installs it for the system version of ruby which is 1.9.1 so I cannot use it with my rvm version which is what apache2 is running. My current work around for all this is to manually ssh in and run bundle install in that directory.
Is there a cleaner way of doing this?
Do I have to have all those exports in my script file?
Update:
Even when I manually go into the directory and run bundle install it puts the gems into vendor/bundle for some reason.
Update:
After entering the following in my before_restart
run "ruby -v"
run "type ruby"
I get this result:
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
ruby is /home/vps/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
I’ve taken out the bundler_args, but it still insists on installing my gems in vendor/bundle for ruby 1.9.1
Running
bundle install --deloymentintentionally places gems in the vendor directory.It’s pretty unlikely that you actually have Ruby 1.9.1 installed. If you are using a Debian-derived distribution then it’s because the package is misnamed as 1.9.1 when it actually installs 1.9.2.
Otherwise I’m not really sure why your
rvm use 1.9.2line would not be taking effect. Dorun "ruby -v"perhaps in the before_restart script and check the version orrun "type ruby"to check its path.