我正在使用 capistrano、capistrano/rbenv、capistrano/bundler 和 capistrano/rails。我在 capistrano 编译资产的步骤中收到此错误:
DEBUG [49a50df6] /usr/bin/env:
DEBUG [49a50df6] ruby
DEBUG [49a50df6] : No such file or directory
DEBUG [49a50df6]
在生产服务器/usr/bin/env ruby -v
上是正确的。我知道这一点:why-does-something-work-in-my-ssh-session-but-not-in-capistrano
但我无法让它工作。
这是我的Capfile
:
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails/tree/master/assets
# https://github.com/capistrano/rails/tree/master/migrations
#
# require 'capistrano/rvm'
require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
这是我的deploy.rb
:
# rbenv
set :rbenv_type, :user
set :rbenv_ruby, '2.0.0-p247'
# bundler
set :bundle_gemfile, -> { release_path.join('Gemfile') }
set :bundle_dir, -> { shared_path.join('bundle') }
set :bundle_flags, '--deployment --quiet'
set :bundle_without, %w{development test}.join(' ')
set :bundle_binstubs, -> { shared_path.join('bin') }
set :bundle_roles, :all
# rails
set :rails_env, 'production'
set :application, 'MY APP'
set :repo_url, 'MY_REPO.git'
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# set :deploy_to, '/var/www/my_app'
# set :scm, :git
# set :format, :pretty
# set :log_level, :debug
# set :pty, true
set :linked_files, %w{.env config/database.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :keep_releases, 5
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end
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
after :finishing, 'deploy:cleanup'
end
这是我的staging.rb
:
set :stage, :staging
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
#role :app, %w{deploy@example.com}
#role :web, %w{deploy@example.com}
#role :db, %w{deploy@example.com}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a has can be used to set
# extended properties on the server.
#server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
server 'my_server', user: 'my_user', roles: %w{web app db}
# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
# fetch(:default_env).merge!(rails_env: :staging)
set :deploy_to, '/home/my_user'
这是完整的跟踪:
INFO [c24b8f94] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p247 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile on 162.243.16.201
DEBUG [c24b8f94] Command: cd /home/my_app/releases/20131101193513 && ( RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p247 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG [c24b8f94] /usr/bin/env:
DEBUG [c24b8f94] ruby
DEBUG [c24b8f94] : No such file or directory
DEBUG [c24b8f94]
cap aborted!
rake stdout: Nothing written
rake stderr: Nothing written
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-rails-1.0.0/lib/capistrano/tasks/assets.rake:61:in `block (6 levels) in <top (required)>'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/abstract.rb:89:in `with'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-rails-1.0.0/lib/capistrano/tasks/assets.rake:60:in `block (5 levels) in <top (required)>'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/abstract.rb:81:in `within'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-rails-1.0.0/lib/capistrano/tasks/assets.rake:59:in `block (4 levels) in <top (required)>'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `run'
/Users/patricio/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:assets:precompile
顺便说一句,我认为它与 无关$PATH
,因为bundle install
运行得很好。
有谁知道发生了什么?
谢谢!