Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I am getting Could not find multi_json-1.3.1 in any of the sources?

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'
like image 486
Soundar Rathinasamy Avatar asked Apr 20 '12 07:04

Soundar Rathinasamy


People also ask

What is a gemlock file?

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.

How do I update my bundler?

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 .


3 Answers

Delete the Gemfile.lock file, and run bundle install. This works for me!

like image 65
Rafael Fidelis Avatar answered Sep 29 '22 04:09

Rafael Fidelis


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.

like image 37
jim Avatar answered Sep 29 '22 02:09

jim


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.

like image 33
Joe Avatar answered Sep 29 '22 02:09

Joe