Reputation: 159
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
Upvotes: 7
Views: 13811
Reputation: 177
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
Upvotes: 3
Reputation: 1224
Remove the code require 'httparty'
wherever you have added.
Upvotes: -4
Reputation: 33471
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.
Upvotes: 4
Reputation: 159
Issue was resolved by installing httparty with sudo, which is weird because I installed httparty as the main admin.
sudo gem install httparty
Upvotes: 7
Reputation: 489
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.
Upvotes: 0