30 Nov 2008, 20:28
Generic-user-small

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_avatar2_pragsmall

Maik Schmidt (113 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

Cheers,

Maik

01 Dec 2008, 13:00
Generic-user-small

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
Password:
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml
01 Dec 2008, 15:15
Maik_schmidt_avatar2_pragsmall

Maik Schmidt (113 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
Generic-user-small

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 $:'
/Library/Ruby/Site/1.8
/Library/Ruby/Site/1.8/powerpc-darwin9.0
/Library/Ruby/Site/1.8/universal-darwin9.0
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/powerpc-darwin9.0
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0
.
Luna:~ sjf$ echo $RUBYLIB

Luna:~ sjf$ 
02 Dec 2008, 18:25
Maik_schmidt_avatar2_pragsmall

Maik Schmidt (113 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.

Cheers,

Maik

02 Dec 2008, 21:21
Generic-user-small

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!

sjf

03 Feb 2009, 14:08
Avatar_pragsmall

Matteo Panara (1 post)

Maybe there is a better solution.

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

require ‘yaml’

Bye!

26 Sep 2009, 14:22
Generic-user-small

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 www.random.org:443 open=false> (NoMethodError)

which method should we call instead ?

thanks

16 Oct 2009, 05:59
Maik_schmidt_avatar2_pragsmall

Maik Schmidt (113 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

Cheers

Maik

  You must be logged in to comment