can't require curb - ruby

Im sure this is another forehead slapper that will turn my face red, but for some reason I'm getting an error when I try to use require 'curb' at the top of my ruby script or in irb:
LoadError: no such file to load -- curb
I ran sudo gem install curb and found I had to run sudo apt-get install libcurl3-gnutls-dev in order to get the gem install to work.
What am I missing here?

Since I am not using a bundler, I had to add require 'rubygems' at the beginning of my list of requires.

Related

HTTParty won't load in Ruby file

I am trying to run a webscraper and when I execute the file I get the following error
/home/luis/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- httparty (LoadError)
from /home/luis/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from luismejia71lbs.rb:1:in `<main>'
I have HTTParty installed and even ran sudo gem install httparty a few times just in case. Not sure why it won't run and I can't find anything concrete. I recently installed rbenv in the last week, not sure if that is related, but since I was able to run httparty in the past.
Here is my file
webscraper.rb
require 'httparty'
require 'nokogiri'
require 'pry'
require 'json'
require 'csv'
craigslist = HTTParty.get('https://miami.craigslist.org/search/mdc/apa?min_bedrooms=3&max_bedrooms=3&min_bathrooms=2&max_bathrooms=2&availabilityMode=0')
Pry.start.(binding)
The error means rbenv can't find the httparty gem. Since rbenv installs gems under ~/.rbenv, you shouldn't need the sudo command to install httparty. Using sudo will almost certainly install in the wrong place. Just do:
$ gem install httparty

LoadError: cannot load such file -- commons-math-2.2.jar

I'm trying to use this gem: Statsample, short blog post about using it
Here is a quick way to reproduce the error (using ruby 2.3.1p112)
gem install statsample
gem install statsample-timeseries
irb
require 'statsample-timeseries'
Result:
LoadError: cannot load such file -- commons-math-2.2.jar
I've tried installing some additional gems/libs but they don't make the error go away.
gem install sciruby-full
apt-get install libcommons-math-java
It's not clear what I'm missing. Do I need to apt-get a certain library? Why is it trying to load a jar?

Ruby: can't require installed gem 'stopwords-filter'

I'm trying to use this this gem, but even though it shows up with a gem list after I install it, a require 'stopwords-filter' in irb results in LoadError: cannot load such file -- stopwords-filter.
To make sure that I was actually able to install and use gems, I also tried installing this gem and I can require it just fine. Everything works.
What am I missing about stopwords-filter?
Thanks!
Even though the gem is named stopwords-filter, the require statement is just stopwords:
require 'stopwords'

Ruby not finding gems, but they appear on gem list, and work in irb console?

I've got a Ruby app using deamon-kit to create a daemon that runs a cron task every 3 seconds.
Problem is I'm trying to add some error checking using Errbit, so that requires me to:
require 'hoptoad_notifier'
in my script. However, the script is complaining it can't find the file?
.rvm/gems/ruby-1.9.2-p320#stitch/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require': no such file to load -- hoptoad_notifier (LoadError)
What confuses me is that the gem is installed, when I run
gem list | grep hoptoad_notifier
I get
hoptoad_notifier (2.4.11)
Another test I did was to pop into irb console, on the same terminal window, after making sure I'm inside the correct RVM gemset off course:
1.9.2p320 :001 > require 'hoptoad_notifier'
=> true
1.9.2p320 :002 >
And voila, hoptoad is loading. It's only when loading my deamon-kit deamon, that I get the error.
What further confuses me is that when I look at my require block:
require 'rubygems'
require 'resque'
require 'hoptoad_notifier'
It's finding rubygems and resque, but not hoptoad_notifier? Why, when I comment out hoptoad, it doesn't also complain about resque and rubygems?
dameon-kit uses bundler, so you don't need to include rubygems. Include the following lines to your Gemfile :
gem 'resque'
gem 'hoptoad_notifier'
Run bundle install
and include your gems as usual :
require 'resque'
require 'hoptoad_notifier'
It worked for me.

I see gem in "gem list" but have "no such file to load"

I am on Ubuntu10
sudo apt-get install ruby1.9.1-full
then download sources of rubygem 1.3.7 and install it
sudo ruby setup.rb
then, for example, install sinatra
sudo gem install sinatra
Finally open irb and type
require "rubygems"
require "sinatra"
and get error
LoadError: no such file to load -- sinatra
from (irb):2:in `require'
from (irb):2
from /usr/bin/irb:12:in `<main>'
I had exactly this problem. The problem is that gem and ruby disagree about where the gems live. Compare these:
ruby -e "puts Gem.path"
gem env
gem which sinatra
If you're like my setup, you'll notice that there's an entry in gem env's paths that isn't in Gem.path, and that's exactly where sinatra will claim to be. In my case, I had to add
export GEM_HOME=/usr/lib/ruby/gems/1.9.1
to my .profile. Then everyone was happy.
Execute
sudo gem install sinatra --verbose
and note the path where the gem is getting installed.
Then try this in irb
puts $LOAD_PATH
and make sure that gem is installed in one of the directories in $LOAD_PATH
And ideally just start using http://rvm.beginrescueend.com/
I usually hit this error when I forget:
require 'rubygems'
It'd be helpful if you provided the actual code sample, though, what gem you want to require, and what Ruby version you're using if this doesn't solve the problem.
This was before here on SO quite a few times. Problem is that you probably have two versions of ruby. The one is installing the gem and the other one is trying to use it. Do this in terminal:
$ which -a ruby
Or this:
$ which -a gem
to see if you have more than one version of ruby/gem installed. If so - remove one version (via $ rm or package manager of your system).
I use ruby gems 1.8.7 for a project. I was getting the same error. Use the line require 'rubygems'. It must always be the first require statement, otherwise you can get an error. In my code, I had
require 'watir'
require 'rubygems'
# more code
I got the error - in `require': no such file to load -- watir (LoadError).
When I put rubygems first, the error went away and everything worked. I don't know
why this happens.
Btw, I tried user24359 answer and it did not help me.
C:\code>ruby -e "puts Gem.path"
-e:1: uninitialized constant Gem (NameError)

Resources