Ruby httparty Load Error

10,276

Solution 1

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

sudo gem install httparty

Solution 2

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.

Solution 3

Try installing the gem:

gem install httparty

Solution 4

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

Share:
10,276
Neil Ricci
Author by

Neil Ricci

BY DAY: Customer service representative BY NIGHT: Aspiring coder, specifically with Ruby and JavaScript "The journey of a thousand miles begins with a single step." -Lao-Tzu

Updated on June 15, 2022

Comments

  • Neil Ricci
    Neil Ricci about 2 years

    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