部署 rails - 无法在任何来源中找到 rake-11.1.2

Deploying rails - Could not find rake-11.1.2 in any of the sources

我正在尝试 运行 cap deploy 一个项目。我一直收到这个错误,我不确定它来自哪里:

    ➜  example git:(master) cap deploy
      * 2016-04-04 19:19:10 executing `deploy'
      * 2016-04-04 19:19:10 executing `deploy:update'
     ** transaction: start
      * 2016-04-04 19:19:10 executing `deploy:update_code'
        executing locally: "git ls-remote git@bitbucket.org:tdelam/example.git HEAD"
        command finished in 807ms
      * executing "git clone -q git@bitbucket.org:tdelam/example.git /srv/rails_apps/example/releases/20160404231911 && cd /srv/rails_apps/example/releases/20160404231911 && git checkout -q -b deploy 24f9d11882b2481d4c2f0cac1fe87095f265cfea && (echo 24f9d11882b2481d4c2f0cac1fe87095f265cfea > /srv/rails_apps/example/releases/20160404231911/REVISION)"
        servers: ["56.223.75.114"]
        [56.223.75.114] executing command
        command finished in 2598ms
      * 2016-04-04 19:19:14 executing `deploy:finalize_update'
        triggering before callbacks for `deploy:finalize_update'
      * 2016-04-04 19:19:14 executing `deploy:assets:symlink'
      * executing "rm -rf /srv/rails_apps/example/releases/20160404231911/public/assets && mkdir -p /srv/rails_apps/example/releases/20160404231911/public && mkdir -p /srv/rails_apps/example/shared/assets && ln -s /srv/rails_apps/example/shared/assets /srv/rails_apps/example/releases/20160404231911/public/assets"
        servers: ["56.223.75.114"]
        [56.223.75.114] executing command
        command finished in 22ms
      * 2016-04-04 19:19:14 executing `bundle:install'
      * executing "cd /srv/rails_apps/example/releases/20160404231911 && bundle install --gemfile /srv/rails_apps/example/releases/20160404231911/Gemfile --path /srv/rails_apps/example/shared/bundle --deployment --quiet --without development test"
        servers: ["56.223.75.114"]
        [56.223.75.114] executing command
     ** [out :: 56.223.75.114] Could not find rake-11.1.2 in any of the sources
        command finished in 6530ms
    *** [deploy:update_code] rolling back
      * executing "rm -rf /srv/rails_apps/example/releases/20160404231911; true"
        servers: ["56.223.75.114"]
        [56.223.75.114] executing command
        command finished in 34ms
    failed: "sh -c 'cd /srv/rails_apps/example/releases/20160404231911 && bundle install --gemfile /srv/rails_apps/example/releases/20160404231911/Gemfile --path /srv/rails_apps/example/shared/bundle --deployment --quiet --without development test'" on 56.223.75.114

我的 capfile 非常简单:

  set :application, "example"
  set :repository, "git@bitbucket.org:tdelam/example.git"

  #set :rvm_type, :system
  set :scm, :git
  # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

  set :user, "jeffc"
  set :deploy_to, "/srv/rails_apps/#{application}"

  set :use_sudo, true

  set :keep_releases, 5

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


  namespace :deploy do
    task :start do ; end
    task :stop do ; end
    task :restart, :roles => :app, :except => { :no_release => true } do
      run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
    end
  end

最后但同样重要的是,这是它抱怨的佣金版本:

➜  example git:(master) rake --version
rake, version 11.1.2

这个 rake 版本既在我的开发机器上也在我的服务器上

编辑:我在服务器上的 ruby 版本是 ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]

这是我的 Gemfile: 来源'https://rubygems.org'

    gem 'rails', '3.2.15'

    group :development, :test do
      gem 'sqlite3'
      gem 'capistrano', '~> 2.15.7'
      gem 'thin'
      #gem 'rvm-capistrano'
    end


    # Gems used only for assets and not required
    # in production environments by default.
    group :assets do
      gem 'sass-rails',   '~> 3.2.3'
      gem 'coffee-rails', '~> 3.2.1'
      gem 'execjs'
      gem 'therubyracer'
      gem 'uglifier', '>= 1.0.3'
    end

    group :production do
      gem 'mysql2','> 0.3'
    end

    gem 'jquery-rails'

    # Refinery CMS
    gem 'refinerycms', '~> 2.1.0'

    # Optionally, specify additional Refinery CMS Extensions here:
    gem 'refinerycms-acts-as-indexed', '~> 1.0.0'

有人对发生的事情有什么建议吗?

确保 bundler 是在没有 sudo 用户的情况下安装的,并尝试从 Capfile 中删除 use_sudo

set :use_sudo, false

为了帮助我创建了一个在 Ubuntu 14.04 上使用 Capistrano 在 rails 项目上创建一个 ruby 的分步步骤: https://gist.github.com/Godoy/7a04acf42a382bd03ed1

在我的项目中效果很好。好运!