7

I am trying to load (require) the httparty gem into a Ruby file but keep getting an error and am unsuccessful.

Below is the error copied:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- httparty (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/neilricci/Desktop/test.rb:1:in `<main>'

Below is where the httparty gem file is located on my computer:

/Users/neilricci/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/httparty-0.13.7/lib/httparty.rb
Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
Neil Ricci
  • 159
  • 1
  • 1
  • 9

6 Answers6

7

Issue was resolved by installing httparty with sudo, which is weird because I installed httparty as the main admin.

sudo gem install httparty
Neil Ricci
  • 159
  • 1
  • 1
  • 9
4

How are you requiring the HTTParty gem in your code? Sometimes an error occurs when you're including your gems with capital letters, that's to say a require "HTTParty" will be clearly different than require "httparty". It can produce a 'require': cannot load such file -- HTTParty (LoadError), what's a name difference; possible solution is to refer your gem require in complete lowercase letter.

Another possible cause could be that your ruby version isn't compatible with what the gem needs, maybe you're running your piece of code with a previous version minor than what the gem needs to work; possible solution is to check what's the Ruby version dependency of the gem that's giving you problems, at the time of writing this the last version of HTTParty is the 0.14.0 what requires a version of Ruby equal or more actual than 1.9.3 (>= 1.9.3)

If your HTTParty gem version is old you're going to receive error messages with undefined methods, here the solution is obvious, check what version do you have and uninstall it using sudo gem uninstall httparty-gem and then install the new version using sudo gem install httparty-gem (sudo is to prevent possible future errors with the propietary who has installed the gem), or if you want you can just install it and have those two or more versions of the gem.

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
3

In my case I had put require 'httparty' on my class but still give me an error. I tried to Install and Uninstall httparty gem without any progress. Finally I could resolve the problem by adding gem 'httparty' line to my Gemfile file followed by running bundle install from command prompt.

I am using rails 5.2.3 with ruby 2.5.1

bradrn
  • 8,337
  • 2
  • 22
  • 51
Hodeifa Baswel
  • 167
  • 1
  • 4
1

Try installing the gem:

gem install httparty
nikkypx
  • 1,925
  • 17
  • 12
0

Your code seems to be running in Ruby 2.0.0, but the gem seems to be installed for Ruby 2.2.3.

Make sure your Ruby version is properly selected through rvm or chruby or whatever you personally use to manage your Ruby versions, and make sure the HTTParty is installed for the same version your code is running in.

jnfjnjtj
  • 409
  • 4
  • 10
-4

Remove the code require 'httparty' wherever you have added.

vitthal-gaikwad
  • 1,184
  • 11
  • 13