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

时间:2016-04-04 23:29:23

标签: ruby-on-rails ruby capistrano

我正在尝试在项目上运行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

最后但并非最不重要的是,这是它抱怨的rake版本:

➜  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'

有没有人建议发生什么事?

1 个答案:

答案 0 :(得分:2)

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

set :use_sudo, false

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

在我的项目中运作良好。祝你好运!