I'm trying to use the HTTParty gem as a part of the gem that I am creating; however I keep getting an uninitialized constant NameError or 'require': cannot load such file -- httparty LoadError. My class starts like this:
module Reporting
class GitlabIssue
include HTTParty
...
Leaving this at it is, I receive the following error:
uninitialized constant Reporting::GitlabIssue::HTTParty (NameError)
Various searches turned up the solution for this is to require 'httparty' before the class block is opened. So I put the following at the top of my file:
require "httparty"
With that in place, I receive this error:
'require': cannot load such file -- httparty (LoadError)
My gemspec has the seemingly correct command to use the gem:
spec.add_dependency "httparty"
and when I do a bundle update/install, it lists the httparty gem as being installed and at version 0.13.3
When I load up an irb session, I can successfully require 'httparty' and it returns true without any errors. Any ideas what could be going on here?
Some system info: I'm running ruby 2.1.0p0 [x86_64-linux] and Rails 4.1.1
I think this has to do with the order that your files (and HTTParty) are loaded in your gem. If you have the standard directory layout for your gem try this:
In your_app.gemspec ->
spec.add_dependency 'httparty'
At the top of your_app/lib/your_app.rb ->
require 'httparty'
I just runned in the exact same issue here .
Turns out I included HTTPParty
instead of HTTParty
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.