Ruby can't load JSON gem?

ruby

Solution

You are running Ruby 1.8+ it appears:

/usr/lib/ruby/site_ruby/1.8

That means your Ruby doesn't automatically load Rubygems, so you'll have to tell it what to do. Try:

require 'rubygems'
require 'json'

Rubygems, called `gem` at the command line, has a number of commands available to you. Try typing this at the command-line:

gem help

for a list of what it can do.

Most useful right now is:

gem list json

for a list of the gems starting with "json" or:

gem search json

for a list of the the gems with "json" in the name.

The goal is to see if the JSON gem is where its supposed to be. If it is, it will show up in the output of the command.

Another useful gem command will be:

gem update --system

which tells Rubygems to update itself. Sometimes the Rubygems application maintainers issue an update, and that command is what we do to tell it to bootstrap itself with the latest version. Because you're running an old version of Ruby, odds are really good that Rubygems is in dire need of an update. But, wait, there's more.

Because you are adjusting your system version of Ruby, you'll need to use:

sudo gem update --system

"sudo" adjusts your account to temporarily have system administration capability.

Once Rubygems has finished upgrading itself, if json didn't appear in the output from `list` or `search`, you'll need to install it using:

sudo gem install json

At that point running the `search` or `list` command should work, and, running your script with the two requires above should work.

Problem

When I try to launch a script requiring the JSON gem, it gives me an error: ``` /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- json (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /home/XXXXXX/XXXXXX/XXXXXX/XXXX.rb:2 ``` Can anyone give me some suggestions?

Original source

Related problems