Capistrano 没有安装
Capistrano doesn't install
每当我尝试 运行 cap production deploy
时,它都会在以下命令中失败
[ebbf9fde] Command: cd /var/www/apps/my_app/releases/20150803171251 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/my_app/shared/bundle --without development test --deployment --quiet
DEBUG [ebbf9fde] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
我添加了一个用户 'deploy' 来执行此部署,rvm list
的输出是
$ rvm list
rvm rubies
=* ruby-2.2.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
进一步运行宁gem列表输出为
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
passenger (5.0.15)
power_assert (0.2.2)
psych (2.0.8)
rack (1.6.4)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.8)
我的Capfile
内容是
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
最后我的 deploy.rb 包含以下数据。
lock '3.4.0'
set :app_host, 'ip-address-here'
set :application, 'my_app'
set :repo_url, 'git@example.com:<not_right>/my_app.git'
set :rvm_type, :system
set :rvm_ruby_version, '2.2.2'
set :passenger_rvm_ruby_version, '2.2.2'
set :rbenv_ruby, '2.2.2'
set :deploy_to, '/var/www/apps/my_app'
set :scm, :git
set :format, :pretty
set :log_level, :debug
set :pty, true
set :conditionally_migrate, true
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
set :keep_releases, 5
set :migrate_env, "#{ fetch(:stage) }"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:web), in: :sequence, wait: 5 do
execute :mkdir, '-p', release_path.join('tmp')
execute :touch, release_path.join('tmp/restart.txt')
end
end
task :httpd_graceful do
on roles(:web), in: :sequence, wait: 5 do
execute :sudo, "service httpd graceful"
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
namespace :deploy_prepare do
desc 'Configure virtual host'
task :create_vhost do
on roles(:web), in: :sequence, wait: 5 do
vhost_redirect_config = <<-EOF
Redirect permanent /#{ fetch(:application) } http://#{ fetch(:app_host) }/#{ fetch(:application) }/
EOF
vhost_location_config = <<-EOF
Alias /#{fetch(:application)} #{fetch(:deploy_to)}/current/public
<Location /#{fetch(:application)}>
PassengerBaseURI /#{ fetch(:application) }
PassengerAppRoot #{ fetch(:deploy_to) }/current/
PassengerRuby /usr/local/rvm/wrappers/ruby-#{ fetch(:rvm_ruby_version) }/ruby
RailsEnv #{ fetch(:stage) }
</Location>
<Directory #{ fetch(:deploy_to) }/current/public >
Allow from all
Options -MultiViews
</Directory>
EOF
execute :echo, "\"#{ vhost_redirect_config }\"", ">", "/etc/httpd/conf.d/redirects/#{ fetch(:application) }.conf"
execute :echo, "\"#{ vhost_location_config }\"", ">", "/etc/httpd/conf.d/apps/#{ fetch(:application) }.conf"
end
end
end
after "deploy:updated", "deploy:cleanup"
after "deploy:finished", "deploy_prepare:create_vhost"
after "deploy_prepare:create_vhost", "deploy:httpd_graceful"
after "deploy:httpd_graceful", "deploy:restart"
我收到以下错误
DEBUG [298e6d4e] Command: cd /var/www/apps/oxygen/releases/20150803172155 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/oxygen/shared/bundle --without development test --deployment --quiet
DEBUG [298e6d4e] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer@162.243.131.67: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deployer@162.243.131.67: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
只需在服务器上尝试 gem install bundler
一次,将捆绑器安装到 rvm gemset 中,因为它不在您的 gem list
列表中。
一般来说,尝试确保在您通过 ssh 登录服务器时运行 bundle
命令。 Capistrano 不会施展魔法,它只是通过 ssh 登录并发出命令。您始终可以看到 Capistrano 发出的命令,例如您的示例 cd /var/www/apps/oxygen/releases/20150803172155 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/oxygen/shared/bundle --without development test --deployment --quiet
并在出现问题时自行尝试。
确保您在正确的 gemset 中安装了 bundler。
我遇到了这个错误并且抓耳挠腮,因为 bundler 安装在默认的 gemset 中,但它不在我用于 rails 应用程序的 gemset 中。
当我意识到这一点时,我就像,"doh!"
只是想我会post这里,希望它能帮助别人。
这对我不起作用,gem install bundler
我意识到我没有正确设置 deploy.rb 文件。
所以因为我使用的是 RVM,所以我检查了 rvm list
的 ruby 版本
jruby-1.7.19 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
然后将我的 deploy.rb 文件配置为 set :rvm_ruby_version, 'ruby-2.2.1'
在您的服务器上
rvm 2.2.2@gemset-name do gem install bundler
来源:https://github.com/capistrano/rvm/issues/65#issuecomment-94108188
每当我尝试 运行 cap production deploy
时,它都会在以下命令中失败
[ebbf9fde] Command: cd /var/www/apps/my_app/releases/20150803171251 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/my_app/shared/bundle --without development test --deployment --quiet
DEBUG [ebbf9fde] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
我添加了一个用户 'deploy' 来执行此部署,rvm list
的输出是
$ rvm list
rvm rubies
=* ruby-2.2.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
进一步运行宁gem列表输出为
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
passenger (5.0.15)
power_assert (0.2.2)
psych (2.0.8)
rack (1.6.4)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.8)
我的Capfile
内容是
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
最后我的 deploy.rb 包含以下数据。
lock '3.4.0'
set :app_host, 'ip-address-here'
set :application, 'my_app'
set :repo_url, 'git@example.com:<not_right>/my_app.git'
set :rvm_type, :system
set :rvm_ruby_version, '2.2.2'
set :passenger_rvm_ruby_version, '2.2.2'
set :rbenv_ruby, '2.2.2'
set :deploy_to, '/var/www/apps/my_app'
set :scm, :git
set :format, :pretty
set :log_level, :debug
set :pty, true
set :conditionally_migrate, true
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
set :keep_releases, 5
set :migrate_env, "#{ fetch(:stage) }"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:web), in: :sequence, wait: 5 do
execute :mkdir, '-p', release_path.join('tmp')
execute :touch, release_path.join('tmp/restart.txt')
end
end
task :httpd_graceful do
on roles(:web), in: :sequence, wait: 5 do
execute :sudo, "service httpd graceful"
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
namespace :deploy_prepare do
desc 'Configure virtual host'
task :create_vhost do
on roles(:web), in: :sequence, wait: 5 do
vhost_redirect_config = <<-EOF
Redirect permanent /#{ fetch(:application) } http://#{ fetch(:app_host) }/#{ fetch(:application) }/
EOF
vhost_location_config = <<-EOF
Alias /#{fetch(:application)} #{fetch(:deploy_to)}/current/public
<Location /#{fetch(:application)}>
PassengerBaseURI /#{ fetch(:application) }
PassengerAppRoot #{ fetch(:deploy_to) }/current/
PassengerRuby /usr/local/rvm/wrappers/ruby-#{ fetch(:rvm_ruby_version) }/ruby
RailsEnv #{ fetch(:stage) }
</Location>
<Directory #{ fetch(:deploy_to) }/current/public >
Allow from all
Options -MultiViews
</Directory>
EOF
execute :echo, "\"#{ vhost_redirect_config }\"", ">", "/etc/httpd/conf.d/redirects/#{ fetch(:application) }.conf"
execute :echo, "\"#{ vhost_location_config }\"", ">", "/etc/httpd/conf.d/apps/#{ fetch(:application) }.conf"
end
end
end
after "deploy:updated", "deploy:cleanup"
after "deploy:finished", "deploy_prepare:create_vhost"
after "deploy_prepare:create_vhost", "deploy:httpd_graceful"
after "deploy:httpd_graceful", "deploy:restart"
我收到以下错误
DEBUG [298e6d4e] Command: cd /var/www/apps/oxygen/releases/20150803172155 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/oxygen/shared/bundle --without development test --deployment --quiet
DEBUG [298e6d4e] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer@162.243.131.67: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deployer@162.243.131.67: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
只需在服务器上尝试 gem install bundler
一次,将捆绑器安装到 rvm gemset 中,因为它不在您的 gem list
列表中。
一般来说,尝试确保在您通过 ssh 登录服务器时运行 bundle
命令。 Capistrano 不会施展魔法,它只是通过 ssh 登录并发出命令。您始终可以看到 Capistrano 发出的命令,例如您的示例 cd /var/www/apps/oxygen/releases/20150803172155 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/oxygen/shared/bundle --without development test --deployment --quiet
并在出现问题时自行尝试。
确保您在正确的 gemset 中安装了 bundler。
我遇到了这个错误并且抓耳挠腮,因为 bundler 安装在默认的 gemset 中,但它不在我用于 rails 应用程序的 gemset 中。
当我意识到这一点时,我就像,"doh!"
只是想我会post这里,希望它能帮助别人。
这对我不起作用,gem install bundler
我意识到我没有正确设置 deploy.rb 文件。
所以因为我使用的是 RVM,所以我检查了 rvm list
的 ruby 版本
jruby-1.7.19 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
然后将我的 deploy.rb 文件配置为 set :rvm_ruby_version, 'ruby-2.2.1'
在您的服务器上
rvm 2.2.2@gemset-name do gem install bundler
来源:https://github.com/capistrano/rvm/issues/65#issuecomment-94108188