我剛剛開始使用git-deploy代替capistrano,問題是雖然我在服務器上使用rvm,但兩者混合不好。git-push和rvm問題
這裏是git的部署鏈接我使用的: https://github.com/mislav/git-deploy
我使用紅寶石通過RVM用戶安裝在我的服務器上1.9.2-P180。當我運行git push和git deploy在部署中運行我的腳本時,它會在vendor/.bundle而不是我的gems目錄中安裝gem:/home/vps/.rvm/gems
這是我的deploy/after_push腳本
#!/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/[email protected]
export RUBY_VERSION=ruby-1.9.2-p180
export PATH=/home/vps/.rvm/gems/ruby-1.9.2-p180/bin:/home/vps/.rvm/gems/[email protected]/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
這裏是我的部署/ 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"
它不僅安裝在供應商/ .bundle但安裝它紅寶石的系統版本是1.9.1,所以我不能用它與我的rvm版本是apache2正在運行的版本。我目前的所有工作都是手動ssh並在該目錄中運行bundle install。
有沒有更乾淨的方式做到這一點?
我是否必須在腳本文件中包含所有這些導出?
更新:
即使我手動進入目錄並運行安裝包,它把寶石爲供應商/捆出於某種原因。
更新:
後進入我的before_restart以下
run "ruby -v"
run "type ruby"
我得到這樣的結果:
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
ruby is /home/vps/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
我已經採取了bundler_args,但它仍然堅持在安裝我的寶石在供應商/捆綁的紅寶石1.9.1