5
votes

I am running the following stack:

  • ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
  • RubyGems 2.2.2
  • Rails 4.1.0
  • Bundler version 1.6.2

on ubuntu running apache

And I am getting the following error:

Could not find json-1.8.1 in any of the sources (Bundler::GemNotFound)

When I look for json as follows:

$ gem list | grep json

json (1.8.1)
multi_json (1.9.2)

It is there but for some reason, the message from Passenger is as follows:

Ruby (Rack) application could not be started

Error message: Could not find json-1.8.1 in any of the sources (Bundler::GemNotFound) Exception class: PhusionPassenger::UnknownError

5
what do you get when you run bundle install ??bjhaid
I just resolved this by removing all json entries from Gemfile.lock and then running bundle install. Thanks!!Arunabh Das
@Das after removing all json entries i am getting can't convert nil into String mysql2 (0.3.15) lib/mysql2/client.rb:67:in connect' mysql2 (0.3.15) lib/mysql2/client.rb:67:in initialize' Do you faced same issue?Sandeeproop

5 Answers

5
votes

For me, this problem was caused by Spring (the Rails quick-loader) not picking up Gem/path changes. I was executing rails generate rspec:install and getting a json-1.8.1 not found.

I probably executed thirty different commands -- any of which probably had an impact to the final resolution -- but eventually doing a bin/spring stop allowed further rails commands to work because they restarted the Spring server with an updated Gem-list.

5
votes

I encountered this a few times in a row when trying to use the rails generate model command in Mac OS X Yosemite. This problem disappeared after I ran gem update rails, despite Terminal outputting "Nothing to update".

I'm running Rails 4.1.7 and ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin14.0].

1
votes

I ran into this exact error while using and .

The issue was that pow couldn't find the gems, so using the solution from rvm, I created a .powenv in the root of the rails app with this content:

# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi

# load environment of current project ruby
if
  [ -n "${rvm_path:-}" ] &&
  [ -x "${rvm_path:-}/bin/rvm" ] &&
  rvm_project_environment=`"${rvm_path:-}/bin/rvm" . do rvm env --path 2>/dev/null` &&
  [ -n "${rvm_project_environment:-}" ] &&
  [ -s "${rvm_project_environment:-}" ]
then
  echo "RVM loading: ${rvm_project_environment:-}"
  \. "${rvm_project_environment:-}"
else
  echo "RVM project not found at: $PWD"
fi

This solved the problem.

0
votes

I had a shell script I created to run unicorn_rails for me that spit out this error even if I ran the exact same command manually. I added --login to the end of hashbang line in the script, and that fixed it.

0
votes

I ran in the same error when running rails command on mac with yosemite

Executing 'rbenv rehash' solved it for me