dtao / safe_yaml

Parse YAML safely
MIT License
217 stars 63 forks source link

Newbie Problem: unable to require safe_yaml: unitialized constant #36

Closed rolandu closed 11 years ago

rolandu commented 11 years ago

Hi,

I'm completely new to ruby and wanted to try the the latest code of "jekyll" (https://github.com/mojombo/jekyll) and run it "myself" (i.e. not installing from gem), but I run into problems with safe_yaml. Maybe it's just a newbie problem I am experiencing?

When I run

ruby jekyll.rb

I get:

/Library/Ruby/Gems/1.8/gems/safe_yaml-0.9.0/lib/safe_yaml.rb:102: uninitialized constant > SafeYAML::Set (NameError) from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:110:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:110:inrequire' from jekyll.rb:21

jekyll.rb:21 says

require 'safe_yaml'

That's why I came here. Is there something wrong with safe_yaml or is there something wrong with my system?

Thanks for any help in advance!

ruby -v ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

rolandu commented 11 years ago

It worked for me after I added the line

require 'set'

to safe_yaml.rb.

dtao commented 11 years ago

Ah, I was scratching my head on this one at first. I recognize that SafeYAML uses the Set class without ever explicitly requiring "set"; but strangely all tests were passing and I couldn't get anything to go wrong locally (on any version of Ruby). What I finally realized was that Bundler itself requires "set" internally; so executing anything using SafeYAML within the context of bundle exec avoids the issue.

I realize you're new, so you might not even know what I'm talking about. Anyway, the important thing is that it makes perfect sense to declare this dependency explicitly in SafeYAML, even if in 99% of cases (almost every Ruby project you'll find these days uses Bundler) it won't make any difference.

Do you want to submit this as a pull request yourself? Might be a nice way to get some GitHub experience :)

If you navigate to safe_yaml.rb and click "Edit" you'll be able to modify the file and and then submit your change. That way when I accept the commit you'll get credit for it!

dtao commented 11 years ago

Thanks! :+1: