I have a simple Rails application I want to deploy to Heroku. When I run the below command
git push heroku master
The below error message is displayed.
Could not find multi_json-1.3.1 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
Here is my Gemfile
gem 'rails', '3.2.3'
gem 'pg'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
The Gemfile. lock allows you to specify the versions of the dependencies that your application needs in the Gemfile , while remembering all of the exact versions of third-party code that your application used when it last worked correctly. By specifying looser dependencies in your Gemfile (such as nokogiri ~> 1.4.
Upgrading applications from Bundler 1 to Bundler 2 Bundler will never change your application to a new major version until you choose to do so. If your application is ready, you can upgrade that application to the latest installed version of Bundler by running bundle update --bundler .
Delete the Gemfile.lock file, and run bundle install. This works for me!
I saw a series of these errors for different gems in spite of the fact I knew these gems were available (e.g. gem list -r <gem>
showed them, including version; browsing rubygems.org showed the version I needed was there and hadn't been yanked etc) and I had a source set (I even set 6 different sources to be sure).
It turned out my problem was I had git stashed
before leaving a feature branch to pull the latest on develop and forgotten to pop the stash afterwards, which was a problem because I had changed my .rvmrc
and not committed the change (to use a newer ruby than our production did).
Because my .rvmrc
specified a gemset for the project, stashing it meant I was suddenly bundling against a gemset that was missing a whole bunch of gems in my Gemfile.lock
and for reasons I don't understand Bundler assumes if the gem is in Gemfile.lock
it's already installed and it doesn't look it up remotely.
So just in case anyone else faces this incredibly frustrating corner case I thought I'd write it up here.
If you are using Capistrano to do your deployments and you mysteriously get "Could not find multi_json-1.7.2 in any of the sources", ensure you have require "bundler/capistrano"
at the top of your config/deploy.rb
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With