我试图将带有Ruby 2.2.3和Capistrano 3的Rails 4.2.4应用程序部署到VPS服务器。我之前已经多次使用RVM完成了这项工作,并且对我的其他应用程序没有任何问题,但是现在我在新机器和服务器上使用rbenv,我得到如下的堆栈跟踪:
DEBUG [a326a4c8] Command: cd /home/deploy/myapp/releases/20151226231303 && /usr/bin/env bundle install --path /home/deploy/myapp/shared/bundle --without development test --deployment --quiet
DEBUG [a326a4c8] /usr/bin/env:
DEBUG [a326a4c8] bundle: No such file or directory
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@youspoof.us: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory
SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing as deploy@youspoof.us: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: /usr/bin/env: bundle: No such file or directory
我在我的服务器上安装了rbenv和ruby 2.2.3 global作为我的部署用户。还安装了gem install bundler
并安装了它。我从服务器运行bundle -v
并获取Bundler version 1.11.2
,因此我知道已安装了bundler。我知道ruby正在使用rbenv shim ruby,因为当我发出which ruby
时,我得到/home/deploy/.rbenv/shims/ruby
。
我不确定这里发生了什么,因为我已经使用过rbenv已经有一段时间了。如果有帮助,这是我的capfile和deploy.rb。
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'
set :rbenv_type, :user
set :rbenv_ruby, '2.2.3p173'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'myapp'
set :repo_url, 'git@github.com:shakycode/myapp.git'
set :deploy_to, '/home/deploy/myapp'
set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
我可能会遗漏一些东西,但每次尝试运行cap production deploy
时,我都会收到有关/ usr / bin / env bundle的调试错误,没有这样的文件或目录。
非常感谢任何帮助。与此同时,我将继续谷歌搜索。
答案 0 :(得分:6)
能够独自一人
require 'capistrano/rbenv'
set :rbenv_path, '/home/deploy/.rbenv/'