ahmet#Ubuntu:~/test$ ruby hello.rb
/home/ahmet/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- watir (LoadError)
from /home/ahmet/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from hello.rb:2:in `<main>'
I have required rubygems in my .rb but still get this error
require 'rubygems'
require 'watir'
According to Watir Readme you have to install and require firewatir. Also you may want to install watir-webdriver instead.
I encountered a similar problem with a different gem a while back on Ubuntu using RVM. I know the gem was installed, because I had just installed it. I did the following:
rvm get latest
rvm reload
gem update --system
Then for good measure I reinstalled the gem, and everything worked. Hope this helps you as well.
Read this: https://github.com/zeljkofilipin/watirbook/blob/master/installation/ubuntu.md
The require should be either 'firewatir' or 'watir-webdriver'
require 'firewatir'
or
require 'watir-webdriver'
Related
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
I have finished writing a ruby script which I would like to share with others, but I am having trouble getting the user to install the necessary gems. I have tried 2 approaches, and a fix for either of them would be greatly appreciated! I require the following gems:
require 'rubygems'
require 'highline/import'
require 'mechanize'
I have tried the following:
1) Generate a stand-alone app with Platypus. I created the Gemfile:
source "https://rubygems.org"
gem "highline", "~> 1.6.20"
gem "mechanize", "~> 2.7.3"
and bundle installed it and included require 'bundler/setup'. I uploaded Gemfile.lock and the ruby script but I receive this error when I run it:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require': cannot load such file -- highline/import (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:inrequire'
from /Users/jonathanli/Documents/CS_projects/iSites/Isites.app/Contents/Resources/script:5:in `'
2) I downloaded the gem files and placed them directly in my host folder. I am unsure of how to modify my require statements, but it is not working as it stands right now.
Thanks in advance everyone! Hope this was enough detail.
I'm having a problem using unroller. I have installed the gem and wrote this simple program to help focus on the problem i'm having:
#!/usr/bin/ruby
require 'rubygems'
require 'unroller'
Unroller::trace
def foo(p1, p2)
puts p1
puts p2
end
foo("param1", "param2")
Running the program yields:
/Library/Ruby/Gems/1.8/gems/facets-2.9.3/lib/core/facets/filetest/separator_pattern.rb:5: warning: already initialized constant SEPARATOR_PATTERN
/Library/Ruby/Gems/1.8/gems/facets-2.9.3/lib/core/facets/string/bracket.rb:3: warning: already initialized constant BRA2KET
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- facets/methodspace (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Gems/1.8/gems/unroller-1.0.0/lib/unroller.rb:4
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
from ./ut:4
My ruby version is ruby 1.8.7 (2011-12-28 patchlevel 357). I also installed ruby on my Windows development box and get the same error and that ruby version is 1.9.3 so it does not appear to be related to the version of Ruby I'm on.
Anyone have any ideas?
Thanks very much in advance!
jon
This is a bug of unroller gem, described here: https://github.com/TylerRick/unroller/issues/1. unroller automatically requires the latest version of facets gem and the version 2.9 breaks it. (BTW gems should never use '>=' when loading dependencies, that's why '~>' is for.)
It's not that difficult to hotfix locally by using bundler and hardcoding facets gem to specific version before requiring unroller (so the specific facets version gets loaded instead of latest 2.9).
create Gemfile:
source 'http://rubygems.org'
gem 'facets', '2.8.4'
gem 'termios' # you're gonna need this gem too, for some reason
gem 'unroller'
run bundle install and then either run the script by bundle exec ruby test.rb or require bundler/setup in it:
require 'rubygems'
require 'bundler/setup'
require 'unroller'
...
UPDATE: or if you don't wanna deal with bundler, try this first, it could work too:
require 'rubygems'
gem 'facets', '2.8.4'
require 'unroller'
...
I am trying to:
require 'nokogiri'
in irb, without success. The Nokogiri gem is installed. From:
gem list --local
I get:
nokogiri (1.4.4, 1.4.3.1)
but when I try to "require" it in irb, I get:
LoadError: no such file to load -- nokogiri
from (irb):8:in `require'
from (irb):8
from :0
Nokogiri 'lives' in:
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/nokogiri-1.4.4/lib
on my system. Also, my GEM PATH (from gem env) is:
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
If I go all the way into the nokogiri gem directory, I can successfully "require" it. But why can't I require it from anywhere else? I am misunderstanding something about the gem path.
Try to require 'rubygems' before requiring nokogiri. If there are no witches on your machine this could help.
Ruby prior to 1.9 didn't automatically do a require 'rubygems' for you. Post 1.9 it does. I always forget when I jump back to 1.8.7 to test something, especially in irb.
You can add require 'rubygems' to your ~/.irbrc file if you want. It won't hurt anything having it there.
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)