# No such file to load Error

**URL:** <https://www.ruby-forum.com/t/no-such-file-to-load-error/184348>\
**Category:** Ruby\
**Created:** [March 1, 2010, 11:01am UTC](https://www.ruby-forum.com/t/no-such-file-to-load-error/184348 "2010-03-01T11:01:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nabusman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8edcca/32.png) [@nabusman](https://www.ruby-forum.com/u/nabusman)\
**Post date:** [March 1, 2010, 11:01am UTC](https://www.ruby-forum.com/t/no-such-file-to-load-error/184348/1 "2010-03-01T11:01:24Z")

</div>

When trying to run the following code I am getting an error which says  
“no such file to load â€” openâ€uri”

require ‘rubygems’  
require ‘mechanize’  
require ‘nokogiri’  
require ‘openâ€uri’

def scrapePage(url, file)  
agent = WWW::Mechanize.new  
page = agent.get(url)  
pp page  
#…  
end

scrapePage(‘[http://google.com](http://google.com)’, ‘dump.txt’)

I have the latest version of Xcode, other details below.

Ruby Version: ruby 1.8.7 (2008-08-11 patchlevel 72)  
[universal-darwin10.0]  
OS: OS X 10.6.2

Thanks

---

<div class="post-metadata">

**Author:** ![nabusman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8edcca/32.png) [@nabusman](https://www.ruby-forum.com/u/nabusman)\
**Post date:** [March 1, 2010, 3:00pm UTC](https://www.ruby-forum.com/t/no-such-file-to-load-error/184348/2 "2010-03-01T15:00:24Z")

</div>

Nabs K. wrote:

> When trying to run the following code I am getting an error which says  
> “no such file to load â€” openâ€uri”  
> …  
> require ‘openâ€uri’

Try just

ruby -ropen-uri -e0

If that gives you the same error, then it looks like your ruby  
installation is broken or incomplete, since it’s a standard part of the  
core library.

$ ls -l /usr/lib/ruby/1.8/open-uri.rb  
-rw-r–r-- 1 root root 20982 2007-10-08 12:16  
/usr/lib/ruby/1.8/open-uri.rb

(This is under Ubuntu Linux rather than Mac, and the ruby version is  
1.8.7p174, but open-uri.rb has been in ruby for years)

Are you sure you haven’t got something odd like an em-dash instead of a  
proper hyphen?

---

<div class="post-metadata">

**Author:** ![nabusman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8edcca/32.png) [@nabusman](https://www.ruby-forum.com/u/nabusman)\
**Post date:** [March 1, 2010, 3:22pm UTC](https://www.ruby-forum.com/t/no-such-file-to-load-error/184348/3 "2010-03-01T15:22:27Z")

</div>

Quick Update: If I run the program via IRB it works fine, but if I try  
to run the program via the Terminal command ruby ‘codeFile.rb’ then it  
gives the same error… So, that means it is not isolated to TextMate as  
I was thinking earlier…

---

<div class="post-metadata">

**Author:** ![nabusman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8edcca/32.png) [@nabusman](https://www.ruby-forum.com/u/nabusman)\
**Post date:** [March 1, 2010, 3:16pm UTC](https://www.ruby-forum.com/t/no-such-file-to-load-error/184348/4 "2010-03-01T15:16:37Z")

</div>

Brian, thanks for the response. I don’t get any error upon running “ruby  
-ropen-uri -e0” in terminal… so I assume that means something is wrong  
with path variables? Also, I should have mentioned that I have been  
running this in TextMate.

After this I tried to run the same program via Terminal and it works  
fine… so it is a TextMate issue… any ideas where I should start to  
solve it in TextMate?

Thanks,

Nabs K.

Brian C. wrote:

> Nabs K. wrote:
> 
> > When trying to run the following code I am getting an error which says  
> > “no such file to load â€” openâ€uri”  
> > …  
> > require ‘openâ€uri’
> 
> Try just
> 
> ruby -ropen-uri -e0
> 
> If that gives you the same error, then it looks like your ruby  
> installation is broken or incomplete, since it’s a standard part of the  
> core library.
> 
> $ ls -l /usr/lib/ruby/1.8/open-uri.rb  
> -rw-r–r-- 1 root root 20982 2007-10-08 12:16  
> /usr/lib/ruby/1.8/open-uri.rb
> 
> (This is under Ubuntu Linux rather than Mac, and the ruby version is  
> 1.8.7p174, but open-uri.rb has been in ruby for years)
> 
> Are you sure you haven’t got something odd like an em-dash instead of a  
> proper hyphen?

---

<div class="post-metadata">

**Author:** ![nabusman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8edcca/32.png) [@nabusman](https://www.ruby-forum.com/u/nabusman)\
**Post date:** [March 1, 2010, 5:17pm UTC](https://www.ruby-forum.com/t/no-such-file-to-load-error/184348/5 "2010-03-01T17:17:49Z")

</div>

Nabs K. wrote:

> Quick Update: If I run the program via IRB it works fine, but if I try  
> to run the program via the Terminal command ruby ‘codeFile.rb’ then it  
> gives the same error… So, that means it is not isolated to TextMate as  
> I was thinking earlier…

Perhaps you have two different versions of ruby. Try running these in  
both ways:

ruby -v

ruby -e ‘require “rbconfig”; puts Config::CONFIG[“rubylibdir”]’

ruby -e ‘puts $:.inspect’

On my box these give respectively:

ruby 1.8.7 (2009-06-12 patchlevel 174) [x86\_64-linux]

/usr/lib/ruby/1.8

["/usr/local/lib/site\_ruby/1.8",  
“/usr/local/lib/site\_ruby/1.8/x86\_64-linux”, “/usr/local/lib/site\_ruby”,  
“/usr/lib/ruby/vendor\_ruby/1.8”,  
“/usr/lib/ruby/vendor\_ruby/1.8/x86\_64-linux”,  
“/usr/lib/ruby/vendor\_ruby”, “/usr/lib/ruby/1.8”,  
“/usr/lib/ruby/1.8/x86\_64-linux”, “.”]

The rubylibdir is where I’d expect open-uri.rb to be found.
