rubycurlcurb

Ruby 2.1 NameError: uninitialized constant Curl


I just finished setting up another development server for my API built using Ruby and Sinatra, however on this server I can't get the curl gem to work properly.

I've installed libcurl and libcurl-devel, and installed the curl gem without any errors, but when I try to use it in code, it always fails. Below is an example in irb:

irb(main):001:0> require 'curl'
=> true
irb(main):002:0> http = Curl.get("http://www.mysuperawesomeapi.com/someendpoint") do|http|
irb(main):003:1* http.headers['accept'] = 'application/JSON'
irb(main):004:1> end
NameError: uninitialized constant Curl
        from (irb):2
        from /usr/bin/irb:11:in `<main>'

The difference between this development server, and the other one is that this one is using Fedora 21 32bit (hardware limitation) while the other is using CentOS 7 64bit and is a virtual machine. When I try the same code above on irb on the CentOS VM, it works as expected. Any insight would be greatly appreciated.


Solution

  • It looks like in curl (unlike as in curb), there is a class CURL, but not Curl.