0

I've got an app running on a box, and I'm trying to add another to the box.

They both use RVM.

The problem is that my deploy process fails for the new app I've added to the box.

When deploying, I call

RVM info 

to see what ruby I'm using. Here's the output:

ruby-1.9.3-p392:

  system:
    uname:       "Linux li83-41 2.6.39.1-linode34 #1 SMP Tue Jun 21 10:29:24 EDT 2011 i686 GNU/Linux"
    system:      "ubuntu/10.04/i386"
    bash:        "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.22.3 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "4 days 21 hours 14 minutes 38 seconds ago"
    path:         "/usr/local/rvm"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p392"
    date:         "2013-02-22"
    platform:     "i686-linux"
    patchlevel:   "2013-02-22 revision 39386"
    full_version: "ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]"

  homes:
    gem:          "/usr/local/rvm/gems/ruby-1.9.3-p392"
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.3-p392"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/gem"
    rake:         "/usr/local/rvm/gems/ruby-1.9.3-p392/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.3-p392"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.3-p392:/usr/local/rvm/gems/ruby-1.9.3-p392@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p392"
    IRBRC:        "/usr/local/rvm/rubies/ruby-1.9.3-p392/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

I'm using bundler, which fails during deploy:

cd #{current_path} && bundle install --deployment

Throwing this error:

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Installing rake (10.1.0)
Installing i18n (0.6.5)
Installing minitest (4.7.5)
Installing multi_json (1.7.9)
Installing atomic (1.1.13)
Installing thread_safe (0.1.2)
Installing tzinfo (0.3.37)
Installing activesupport (4.0.0)
Gem::InstallError: activesupport requires Ruby version >= 1.9.3.
An error occurred while installing activesupport (4.0.0), and Bundler cannot
continue.
Make sure that `gem install activesupport -v '4.0.0'` succeeds before bundling.
rake aborted!

I'm at wits end here: looks like I'm using ruby1.9.3-p392 but bundler is telling me I need ruby >= 1.9.3.

Here's my .bundle/config:

---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_FROZEN: '1'

Also, if I ssh into the box it looks like I'm using the correct ruby:

$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby

And Running bundle install works fine.

Any ideas?

Edit #1

I'm using Vlad, here's deploy.rb:

set :repository,  repo_location
set :revisions,   5
set :revision, "HEAD"
set :domain, domain
set :user,        login_user
set :deploy_to,   deploy_dir
set :deploy_env, "production"

namespace :vlad do

  desc 'Restart Passenger'
  remote_task :restart_app do
    puts "Restarting passenger..."
    run "touch #{current_release}/tmp/restart.txt"
  end

  desc 'Runs our full deployment'
    task :deploy => ['vlad:update', 
                     'vlad:symlink', 
                     'vlad:rvm_info',
                     'vlad:update_bundle',
                     'vlad:migrate_database',
                     'vlad:cleanup', 
                     'vlad:restart_app']

  desc 'Symlinks your custom directories'
  remote_task :symlink do
    run "ln -s #{shared_path}/environments #{latest_release}/config/environments"
    run "ln -s #{shared_path}/database.yml #{current_path}/config/database.yml"
    run "ln -s #{shared_path}/config.yml #{current_path}/config/config.yml"
  end

  desc 'Show RVM Info for debug purposes'
  remote_task :rvm_info do
    run "cd #{current_path} && rvm info" 
  end

  desc 'Update the Bundler bundle we use to include any new gems in the Gemfile'
  remote_task :update_bundle do
    run "cd #{current_path} && bundle install --deployment" 
  end

  # copied from the vlad source, integrate migrate does not work as it's missing
  # the && between the cd and the db migrate task itself. bug is already tracked
  # at http://rubyforge.org/tracker/?group_id=4213&atid=16258&func=detail&aid=28445, 
  # but currently does not do anything.
  remote_task :migrate, :roles => :app do
    break unless target_host == Rake::RemoteTask.hosts_for(:app).first

    directory = case migrate_target.to_sym
                when :current then current_path
                when :latest  then latest_release
                else raise(ArgumentError, "unknown migration target #{migrate_target.inspect}")
                end

    run(["cd #{directory}", 
         "bundle exec #{rake_cmd} db:migrate #{migrate_args} RAILS_ENV=#{rails_env}"].join(" && "))
  end

end
4

1 回答 1

0

这不是 rvm 错误...这是您如何运行命令的问题,vlad不使用登录会话,ssh因此您需要手动加载 rvm:

set :command_prefix, [". `/usr/local/rvm/bin/rvm . do rvm env --path`"]

我无法测试它——基于 vlad 代码——但这应该是一个好的开始。

于 2013-09-04T23:31:54.293 回答