Could not find rake-10.0.3 in any of the sources

2019-01-25 05:19发布

问题:

I successfully installed a Rails (3.2.10) app on an Ubuntu 12.04 server on Rackspace following Railscasts 335 deploying to a vps. Nginx, Unicorn, rbenv and Capistrano.

Then, when I try to install a second rails website I get the error "Could not find rake-10.0.3 in any of the sources" during cap:deploy. cap:setup and cap:check were successful. Additionally, there is no current directory under my application folder.

If I cd into the releases directory and run bundle install it is using rake-10.0.3. The only difference between the two apps is that the new app I am trying to install uses the assets pipeline.

Here is my deploy file which is identical for both apps, except for the set :application directive.

set :user, 'mark'
set :scm_passphrase, 'xxxx'
set :domain, '99.99.99.99'
set :application, "my_app"

set :repository,  "#{user}@#{domain}:git/#{application}.git"

ssh_options[:forward_agent] = true

set :deploy_to, "/var/www/#{application}"

role :app, domain
role :web, domain
role :db,  domain, :primary => true

default_run_options[:pty] = true

set :deploy_via, :remote_cache

set :scm, 'git'
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_#{application} #{command}"
    end
  end

  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
    sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"

  task :symlink_config, roles: :app do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
  after "deploy:finalize_update", "deploy:symlink_config"

  desc "Make sure local git is in sync with remote."
  task :check_revision, roles: :web do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts "WARNING: HEAD is not the same as origin/master"
      puts "Run `git push` to sync changes."
      exit
    end
  end
  before "deploy", "deploy:check_revision"
end

回答1:

Remove all the versions of Rake ==> gem uninstall rake
Remove Gemfile.lock ==> rm Gemfile.lock
Run bundle install ==> bundle install

gem install rake --version=10.0.2

if you still get the error then put this into your gemfile.

gem 'rake', '0.8.7'


回答2:

bundle update rake

worked for me. I've had similar problem.



回答3:

If your still looking for a fix... For me it was a matter of using sudo bundle install instead of just bundle install.



回答4:

I had this same cryptic error message .... turns out I had created a 'cloned' release inside the release folder which causes sprockets to want to do things there .... I think cap uses the create date as it traverses the release tree so somehow this messed things up .... be sure there are no additional 'hand made' folders in your /releases/ folder and you should get past this bug



回答5:

I had the same problem. The cause for my problem was that Rake was also found in /usr/bin/local/ in addition to being in the shims directory in rbenv. To check if this is the problem first uninstall rake gem uninstall rake then run which rake. If you get back a path that is different than /Users/username/.rbenv/shims/rake then just remove that binary using sudo rm /path/to/file.

Note that in my case at least, which gem was using a shimed executable that was managed by rbenv, while rake wasn't. So everything worked find until I tried to invoke rake command from the terminal.

Also see: After installing rbenv and changing Ruby version, Rake no longer runs



回答6:

For rails version from 4.3, let try with bundle exec rails app:update. It worked for me.

Hope it's useful for you.