0

我正在尝试使用 Capistrano 和 RVM 进行部署,即使在运行时cap bundler:install_bundler应该安装捆绑程序并成功。之后,运行cap deploy时失败,并显示未安装捆绑程序的错误。

** [out :: victorstan.com] ERROR: Gem bundler is not installed, run `gem install bundler` first.

任何想法为什么它安装捆绑器,但找不到它,或者将它安装在错误的位置(我猜?)。谢谢!

这是我的 deploy.rb 脚本的一部分:

set :application,       "dinner"
set :domain,            "victorstan.com"
set :repository,        "ssh://#{domain}/~/#{application}.git"
set :use_sudo,          false
set :user,              "victorstan"  # The server's user for deploys
set :scm,               :git
set :scm_username,      "passenger"
set :deploy_to,         "/srv/www/#{application}"
set :keep_releases,     2
set :branch,            "master"
set :deploy_via,        :copy # won't make cap prompt for password when deploying
set :scm_verbose,       true
set :rvm_ruby_string,   'ruby-2.0.0-p195@dinner'
set :rvm_type,          :user
set :rvm_install_type,  :stable
set :whenever_command,  "bundle exec whenever"


require "bundler/capistrano"
require "rvm/capistrano"
require "whenever/capistrano"

如果我尝试使用 cap 安装 bundler,它可以工作:

cap bundler:install_bundler
  * 2013-06-08 15:33:54 executing `bundler:install_bundler'
  * executing "gem install bundler"
    servers: ["victorstan.com"]
    [victorstan.com] executing command
 ** [out :: victorstan.com] Successfully installed bundler-1.3.5
 ** [out :: victorstan.com] 1 gem installed
    command finished in 1373ms

这是运行时的输出cap deploy

Switched to a new branch 'deploy'
    command finished in 984ms
  * Compressing /var/folders/w4/_6g_9lqd491_6cmhzb0kcmzh0000gn/T/20130608192600 to /var/folders/w4/_6g_9lqd491_6cmhzb0kcmzh0000gn/T/20130608192600.tar.gz
    executing locally: tar czf 20130608192600.tar.gz 20130608192600
    command finished in 53ms
    servers: ["victorstan.com"]
 ** sftp upload /var/folders/w4/_6g_9lqd491_6cmhzb0kcmzh0000gn/T/20130608192600.tar.gz -> /tmp/20130608192600.tar.gz
    [victorstan.com] /tmp/20130608192600.tar.gz
    [victorstan.com] done
  * sftp upload complete
  * executing "cd /srv/www/dinner/releases && tar xzf /tmp/20130608192600.tar.gz && rm /tmp/20130608192600.tar.gz"
    servers: ["victorstan.com"]
    [victorstan.com] executing command
    command finished in 467ms
  * 2013-06-08 15:26:05 executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * 2013-06-08 15:26:05 executing `bundle:install'
  * executing "cd /srv/www/dinner/releases/20130608192600 && bundle install --gemfile /srv/www/dinner/releases/20130608192600/Gemfile --path /srv/www/dinner/shared/bundle --deployment --quiet --without development test"
    servers: ["victorstan.com"]
    [victorstan.com] executing command
 ** [out :: victorstan.com] ERROR: Gem bundler is not installed, run `gem install bundler` first.
    command finished in 598ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /srv/www/dinner/releases/20130608192600; true"
    servers: ["victorstan.com"]
    [victorstan.com] executing command
    command finished in 513ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-2.0.0-p195@dinner' -c 'cd /srv/www/dinner/releases/20130608192600 && bundle install --gemfile /srv/www/dinner/releases/20130608192600/Gemfile --path /srv/www/dinner/shared/bundle --deployment --quiet --without development test'" on victorstan.com
4

2 回答 2

0

我已经阅读了更多关于设置部署脚本的示例,并且我重新安排了部署脚本的元素顺序,以及 ena

set :application,       "dinner"
set :domain,            "victorstan.com"
set :repository,        "ssh://#{domain}/~/#{application}.git"
set :use_sudo,          false
set :user,              "victorstan"  # The server's user for deploys
set :scm,               :git
set :scm_username,      "passenger"
set :scm_passphrase,    "*********"  # The deploy user's password
set :deploy_to,         "/srv/www/#{application}"
set :keep_releases,     2
set :branch,            "master"
set :deploy_via,        :copy # won't make cap prompt for password when deploying
set :scm_verbose,       true
set :rvm_ruby_string,   :local
set :rvm_type,          :user
set :rvm_install_type,  :stable
set :default_shell,     :bash
set :whenever_command,  "bundle exec whenever"

default_run_options[:pty] = true

# before 'deploy', 'rvm:install_ruby'
before 'deploy:setup', 'rvm:install_ruby'

require "rvm/capistrano"
require "bundler/capistrano"
require "whenever/capistrano"

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

一些值得注意的变化:

set :rvm_ruby_string设置为:local 而不是明确命名它:'ruby-2.0.0-p195@dinner',但不确定这是否对这个问题有任何影响,似乎不太可能。

set :default_shell, :bash是我添加的另一个参数。

而且,正如我所提到的,排序或不同的 DSL 类型可能会有所不同:set首先是before钩子,然后requirerole部署脚本的其余部分。也许这可以帮助处于类似情况的人。

请注意,当我第一次测试这个脚本时,我已经before 'deploy', 'rvm:install_ruby'启用,但我已经禁用它并且脚本继续工作......

于 2013-06-09T15:38:06.917 回答
0

在服务器上ruby-2.0.0-p195@dinner安装/创建?

你可以确保它是通过添加:

before 'deploy:setup', 'rvm:install_ruby'

关于使用的更多细节rvm-capistrano可以在这里找到:https ://github.com/wayneeseguin/rvm-capistrano#readme

于 2013-06-08T20:58:07.903 回答