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 di
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
.
For me this was caused because Pow (local rack server) was not using the correct RVM ruby version/gemset.
Fixed by adding the following .powrc
:
# based on https://coderwall.com/p/pkj39a
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-version`@`cat .ruby-gemset`
fi
Source: https://coderwall.com/p/pkj39a
I have solved it by the following steps.
Removed Gemfile.lock
bundle install
The cause of the problem is initially my Gemfile.lock has multi_json-1.3.1
Now it has the version multi_json-1.3.2
Delete the Gemfile.lock file, and run bundle install. This works for me!
In my case, I was lacking
source 'https://rubygems.org'
in Gemfile
. My suspicion is that old versions of bundler can operate without a source being mentioned, but newer versions can't.