【问题标题】:capistrano deploy error on ubuntu - Could not find bundlerubuntu 上的 capistrano 部署错误 - 找不到捆绑程序
【发布时间】:2011-11-03 21:55:16
【问题描述】:

这是在 ubuntu 和 rvm 上使用 cap deploy 执行 deploy.rb 的输出:

执行.../bin/bundle install vendor/gem时报错:

  * executing "cd /vol/www/emclab/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
    servers: ["12.34.56.78"]
    [12.34.56.78] executing command
*** [err :: 12.34.56.78] /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
*** [err :: 12.34.56.78] from /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
*** [err :: 12.34.56.78] from /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
*** [err :: 12.34.56.78] from /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle:18:in `<main>'
    command finished in 624ms
failed: "sh -c 'cd /vol/www/emclab/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems'" on 12.34.56.78

这里是 cap invoke COMMAND='which bundle' 的输出:

 ** [out :: 12.34.56.78] /usr/local/bin/bundle

这里是 deploy.rb:

set :application, "myapp"
set :repository,  "git://github.com/myapp/myapp.git"
set :scm, :git
set :user, "dtt"
set :use_sudo, true
set :scm_passphrase, "phrase"
set :branch, "master"
set :deploy_to, "/vol/www/#{application}"
#set :deploy_via, :remote_cache

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

server "12.34.56.78", :web, :app, :db, :primary => true
#role :web, "your web-server here"                          # Your HTTP server, Apache/etc
#role :app, "your app-server here"                          # This may be the same as your `Web` server
#role :db,  "your primary db-server here", :primary => true # This is where Rails migrations will run
#role :db,  "your slave db-server here"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"
# If you are using Passenger mod_rails uncomment this:
 namespace :deploy do
   task :bundle_gems do
     run "cd #{deploy_to}/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
   end
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
 end

关于错误的任何建议?谢谢。

【问题讨论】:

    标签: ruby-on-rails ubuntu capistrano


    【解决方案1】:

    让 cap 连接并告诉你 bundle 的安装位置

    cap invoke COMMAND='which bundle'
    

    如果未找到 bundle 命令,则说明您的 PATH 设置不正确。您可能需要在该主机上运行的 sshd 中使用 PermitUserEnvironment。然后可以在部署用户的.ssh/environment文件中手动设置路径。

    【讨论】:

    • 它是 /usr/local/bin/bundle 用于较旧的 ruby​​ 版本 p180。该错误可能是由 sudo 和 rvm 引起的。捆绑器是为 ruby​​ p290 安装的。但是 cap 仍然调用 ruby​​ p180 中的 bundle 来执行。怎么修?谢谢。
    • 我手动运行命令:rvmsudo /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems under /current.它似乎通过了。
    【解决方案2】:

    bundler 是否安装在远程机器上?

    在您的日志中某处显示:

    Could not find bundler (>= 0)
    

    【讨论】:

      【解决方案3】:

      问题可能是您需要创建捆绑程序包装器。你可以这样做(例如在你的 deploy.rb 中)

      require "rvm/capistrano" # http://beginrescueend.com/integration/capistrano/
      
      # rvm-capistrano settings
      set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
      
      namespace :rvm do
        task :create_bundle_wrapper, roles: :app do
          run "rvm wrapper #{rvm_ruby_string} bundle bundle"
        end  
      end
      
      after "deploy:create_symlink", "rvm:create_bundle_wrapper"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-03
        • 1970-01-01
        相关资源
        最近更新 更多