我刚刚开始使用git-部署而不是capistrano,但问题是我在服务器上使用了rvm,而两者并不是很好地混合在一起。
下面是我正在使用的git部署的链接:https://github.com/mislav/git-deploy
我在通过rvm为用户安装的服务器上使用ruby1.9.2-P 180。当我运行git push和git部署时,它在部署中运行我的脚本,它在供应商/..bundle中安装gems,而不是在我的gems目录中安装:/home/vps/..rvm/gems
下面是我的部署/后置推送脚本
#!/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这是我的部署/重新启动前
#!/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中,而且还将其安装到ruby的系统版本( 1.9.1 )中,因此我不能将它与apache2正在运行的rvm版本一起使用。我目前所做的工作是在这个目录中手动执行ssh并运行bundle install。
有更干净的方法吗?
是否必须将所有这些导出都包含在脚本文件中?
更新:
即使我手动进入目录并运行bundle安装,出于某种原因,它也会将宝石放入供应商/包中。
更新:
在我的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,但它仍然坚持在ruby 1.9.1的供应商/包中安装我的宝石
发布于 2011-11-25 09:56:55
故意运行bundle install --deloyment 将宝石放置在供应商中目录。
您不太可能实际安装了Ruby1.9.1。如果您使用的是Debian派生的发行版,那么这是因为当包实际安装1.9.2时,它被错误地命名为1.9.1。
否则,我不太清楚为什么您的rvm use 1.9.2行不会生效。执行run "ruby -v" (可能在before_restart脚本中)并检查版本或run "type ruby"以检查其路径。
https://stackoverflow.com/questions/8266299
复制相似问题