Rails 4 Capistrano部署找不到activesupport

Rails 4 Capistrano deployment cannot find activesupport

我正在尝试通过 Capistrano 从我的本地机器部署到我的部署服务器。当我部署时,它连接到服务器然后转储出以下信息。

** sftp upload /var/folders/x0/hyzt7pms0599ymtyjft739kw0000gn/T/20160406223514.tar.gz -> /tmp/20160406223514.tar.gz
    [address] /tmp/20160406223514.tar.gz
    [address] done
  * sftp upload complete
  * executing "cd /var/www/address/releases && tar xzf /tmp/20160406223514.tar.gz && rm /tmp/20160406223514.tar.gz"
    servers: ["address"]
    [address] executing command
    command finished in 519ms
  * 2016-04-06 18:35:59 executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * 2016-04-06 18:35:59 executing `deploy:assets:symlink'
  * executing "rm -rf /var/www/address/releases/20160406223514/public/assets && mkdir -p /var/www/address/releases/20160406223514/public && mkdir -p /var/www/address/shared/assets && ln -s /var/www/address/shared/assets /var/www/address/releases/20160406223514/public/assets"
    servers: ["server"]
    [server] executing command
    command finished in 48ms
  * executing "chmod -R -- g+w /var/www/address/releases/20160406223514 && rm -rf -- /var/www/address/releases/20160406223514/public/system && mkdir -p -- /var/www/address/releases/20160406223514/public/ && ln -s -- /var/www/address/shared/system /var/www/address/releases/20160406223514/public/system && rm -rf -- /var/www/address/releases/20160406223514/log && ln -s -- /var/www/address/shared/log /var/www/address/releases/20160406223514/log && rm -rf -- /var/www/address/releases/20160406223514/tmp/pids && mkdir -p -- /var/www/address/releases/20160406223514/tmp/ && ln -s -- /var/www/address/shared/pids /var/www/address/releases/20160406223514/tmp/pids"
    servers: ["address"]
    [address] executing command
    command finished in 49ms
    triggering after callbacks for `deploy:update_code'
  * 2016-04-06 18:35:59 executing `deploy:assets:precompile'
    triggering before callbacks for `deploy:assets:precompile'
  * 2016-04-06 18:35:59 executing `deploy:assets:update_asset_mtimes'
  * executing "[ -e '/var/www/address/shared/assets/.sprockets-manifest*' ] && cat /var/www/address/shared/assets/.sprockets-manifest* || echo"
    servers: ["address"]
    [server] executing command
    command finished in 31ms
  * executing "cd -- /var/www/address/releases/20160406223514 && RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile"
    servers: ["address"]
    [address] executing command
 ** [out :: address] Could not find activesupport-4.2.0 in any of the sources
 ** [out :: address] Run `bundle install` to install missing gems.
    command finished in 547ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/address/releases/20160406223514; true"
    servers: ["address"]
    [address] executing command
    command finished in 57ms
failed: "sh -c 'cd -- /var/www/address/releases/20160406223514 && RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile'" on address

它说它找不到activesupport,但是当我在服务器上运行 gem列出时,它被列出并显示版本4.2.6、4.2.4、4.2.0。

这是权限问题?

这里是deploy.rb

set :application, "app"
set :repository,  "repo"

set :deploy_to, '/var/www/address'
set :scm, :git
set :branch, "master"

set :user, "user"

set :use_sudo, false

set :rails_env, "production"
set :deploy_via, :copy

set :keep_releases, 5

default_run_options[:pty] = true

server "address", :app, :web, :db, :primary => true


namespace :deploy do
    desc "Symlink shared config files"
    task :symlink_config_files do
        run "#{ try_sudo } ln -s #{ deploy_to }/shared/config/database.yml #{ current_path }/config/database.yml"
    end

    desc "Restart Passenger app"
    task :restart do
        run "#{ try_sudo } touch #{ File.join(current_path, 'tmp', 'restart.txt') }"
    end
end


after "deploy", "deploy:symlink_config_files"
after "deploy", "deploy:restart"
after "deploy", "deploy:cleanup"

我的猜测是,在尝试进行资产预编译之前,您似乎没有在 capistrano 脚本中启动 bundle install

运行 预先安装一个包,它应该可以正常工作。

编辑:require 'capistrano/rails'(或 require 'capistrano/bundler')在您的 Capfile 中。

来源:https://github.com/capistrano/rails