small medium large xlarge

30 Nov 2008, 20:28
Steven Finnegan (19 posts)

When I try to run this program (convenient_password.rb) I get the following errors.

/Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- YAML (LoadError)
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
	from /Library/Ruby/Gems/1.8/gems/ngrams-0.1.0/lib/ngrams/ngrams.rb:24
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
	from /Library/Ruby/Gems/1.8/gems/ngrams-0.1.0/lib/ngrams.rb:2
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:32:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:32:in `require'
	from /Users/sjf/Desktop/conv_pswds.rb:32

I have the ngrams gem installed.

01 Dec 2008, 07:32
Maik Schmidt (121 posts)

Hi, Steven!

The ngrams gem needs the YAML library and tries to require it in line 24 of the file /Library/Ruby/Gems/1.8/gems/ngrams-0.1.0/lib/ngrams/ngrams.rb. Unfortunately, it cannot be found on your system although it’s part of the Ruby standard library (at least in version 1.8 which seems to be the version you’re using). Could you check, if you can reproduce the following irb session:

$ irb » require ‘yaml’ => true » require ‘YAML’ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/YAML.rb:87: warning: already initialized constant Resolver /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/YAML.rb:88: warning: already initialized constant DefaultResolver /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/YAML.rb:90: warning: already initialized constant GenericResolver /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/YAML.rb:91: warning: already initialized constant Parser /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/YAML.rb:92: warning: already initialized constant Emitter => true



01 Dec 2008, 13:00
Steven Finnegan (19 posts)

Thanks for your help, Maik!

Well, you’re right, it’s not found. For what its worth, this is running under OS X Leopard. I believe I have everything updated to current releases.

Luna:~ sjf$ irb
>> require 'yaml'
=> false
>> require 'YAML'
LoadError: no such file to load -- YAML
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from (irb):2

>> quit
Luna:~ sjf$ ruby --version
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
Luna:~ sjf$ 

Interestingly, it DOES seem to be on the disk…

Luna:~ sjf$ sudo find / -name yaml
01 Dec 2008, 15:15
Maik Schmidt (121 posts)

I guess there’s something wrong with your load path. What’s the output of the following two commands:

$ ruby -e ‘puts $:’ $ echo $RUBYLIB

01 Dec 2008, 15:52
Steven Finnegan (19 posts)

I have 2 Macs (both intel) – both behave the same (though one may not be as current). Both return the following to your two commands:

Luna:~ sjf$ ruby -e 'puts $:'
Luna:~ sjf$ echo $RUBYLIB

Luna:~ sjf$ 
02 Dec 2008, 18:25
Maik Schmidt (121 posts)

Hi, Steven!

I have setup a complete new Ruby environment in a Parallels virtual machine on Windows XP. I could not fully reproduce your problem, but found some strange behavior regarding the name of the YAML library. Please replace @require ‘YAML’@ in line 24 of ngrams.rb with @require ‘yaml’@ and try again.



02 Dec 2008, 21:21
Steven Finnegan (19 posts)

YES! That worked! Now that I see the problem, I should mention (ahem) that my macs are set up with case-sensitive filesystems. This was done because when developing RoR systems on a non-case-sensitive mac, I would then have problems with the deployed versions running under FreeBSD, which is case-sensitive. Looks like somebody is assuming a non-case-sensitive FS.

Thanks for all your help!


03 Feb 2009, 14:08
Matteo Panara (1 post)

Maybe there is a better solution.

Create YAML.rb in your app lib path with this line:

require ‘yaml’


26 Sep 2009, 14:22
jonathan belolo (3 posts)

Hi, as mentioned in the errata, the method enable_post_connection_check seems to be deprecated… which could explain why I get this error :

random_org_password.rb:27:in send_request': undefined method enable_post_connection_check’ for #<Net::HTTP open=false> (NoMethodError)

which method should we call instead ?


16 Oct 2009, 05:59
Maik Schmidt (121 posts)

The enable_post_connection_check method has been removed, because the check is performed by default now. You can turn it off by setting Net::HTTP#verify_mode= OpenSSL::SSL::VERIFY_NONE.

To make your code portable use the following statement:

https.enable_post_connection_check = true if https.respond_to? :enable_post_connection_check



You must be logged in to comment