Dirk
Dirk

Reputation: 3221

Ruby - require 'watir-webdriver' - generates a LoadError no such file... Why?

I am new to Ruby and would really appreciate some help understanding what is going on here.
Summary:

Gem install watir-webdriver
Installs fine
start irb
require "watir-webdriver"
... LoadError: no such file to load --watir-webdriver

Surely this should respond

=> true

Why is it not finding the gem? Or what am I doing wrong?

Console

I'm on win7, Railsinstaller (Ruby 1.8.7).

Upvotes: 7

Views: 8217

Answers (3)

Marnen Laibow-Koser
Marnen Laibow-Koser

Reputation: 6337

In Ruby 1.8.7, require won't locate gems unless you do require 'rubygems' first. (Ruby 1.9 loads gems without this.)

I highly, highly recommend using Bundler for managing gem dependencies. If you weren't on Windows, I'd recommend RVM as well; I understand that Pik may do something similar for Windows, but I've never used it.

Upvotes: 3

Steve
Steve

Reputation: 15736

In 1.8.7 you need to require rubygems first.

require 'rubygems'

Some explanation here: How does require rubygems help find rubygem files?

Upvotes: 13

muffinista
muffinista

Reputation: 6736

Depending on your setup, you might need to require 'rubygems' first, like so:

$ irb
>> require 'rubygems'; require 'watir-webdriver'
=> true

Upvotes: 5

Related Questions