Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakefile fix for a Psych error when building the gem #6

Closed
wants to merge 1 commit into from

Conversation

aledalgrande
Copy link

This fixes the error:

undefined method `yaml' for #<Psych::Nodes::Stream:0x007fdb74030b18>

happening when running rake gem.

Env:

  • RUBYGEMS VERSION: 1.8.12
  • RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.2.0]
  • RVM
  • bundler 1.1.rc.7

```
undefined method `yaml' for #<Psych::Nodes::Stream:0x007fdb74030b18>
```

happening when running `rake gem`.

Env:
- RUBYGEMS VERSION: 1.8.12
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.2.0]
- RVM
- bundler 1.1.rc.7
@ser1zw
Copy link
Member

ser1zw commented Feb 6, 2012

Thanks for your pull request!

But the error doesn't occur in my environment.
Could you tell me more about the error and the solution?
(ex. details of the cause of the error, why the solution fix it, full stack trace, ...)

My environments and result are:

Env 1:

  • ruby 1.9.2p290 [i686-linux]
  • rvm 1.10.0
  • rubygems 1.8.15
  • bundler 1.1.rc.7

Env 2:

  • ruby 1.9.3p0 [i686-linux]
  • rvm 1.10.0
  • rubygems 1.8.15
  • bundler 1.0.21
$ rake gem
mkdir -p pkg
mkdir -p pkg
mkdir -p pkg/opencv-0.0.6
...
cd pkg/opencv-0.0.6
mv opencv-0.0.6.gem ..
cd -

$ gem install pkg/opencv-*.gem -- --with-opencv-dir=/path/to/opencvdir
Building native extensions.  This could take a while...
Successfully installed opencv-0.0.6
1 gem installed

$ irb
1.9.2p290 :001 > require 'opencv'
 => true 
1.9.2p290 :002 > OpenCV::VERSION
 => "0.0.6" 
1.9.2p290 :003 > 

@aledalgrande
Copy link
Author

Hi, same RVM version as you, the only difference is that I'm on a Mac (Lion).

The full error I was getting was:

$ rake gem
/Users/ale/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.2.2/lib/psych.rb:93: warning: already initialized constant VERSION
/Users/ale/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.2.2/lib/psych.rb:96: warning: already initialized constant LIBYAML_VERSION
cd pkg/opencv-0.0.6
rake aborted!
undefined method `yaml' for #<Psych::Nodes::Stream:0x007fdb74030b18>

Tasks: TOP => gem => pkg/opencv-0.0.6.gem

Also I noticed that the filename of the gem is not the same exact version as in the gemspec (i.e. 0.0.6.20111221003947), but couldn't report that as there is not an issue section for this project seems it has been created now.

Thanks

@ser1zw
Copy link
Member

ser1zw commented Feb 7, 2012

Hi,
I investigated the cause of the problem.
I found this problem occurs in the case that you installed Psych 1.2.2 using rubygems.

Cause of the problem

When system Psych and Psych gem exist together, they conflict with each other when executing require 'yaml'.
The following comment explains the detail:
rubygems/bundler#1541 (comment)

Psych 1.2.2 defines Psych::Nodes::Stream#yaml and uses it internally. But it is not defined in 1.2.1 or older (installed as system Psych). This causes the NoMethodError.

Solution

Your solution works well by RC version of bundler, but doesn't work well by the latest stable version (bundler 1.0.21).

I think we should adopt a different way, refering the bundler's solution:
https://github.com/carlhuda/bundler/blob/v1.1.rc.7/lib/bundler/psyched_yaml.rb

@aledalgrande
Copy link
Author

Nice job! I did have that gem installed in fact. Will close this then.

Thanks

wbharding pushed a commit to bonanza-market/ruby-opencv that referenced this pull request Nov 6, 2014
Fix this problem: ruby-opencv#6
Thanks for aledalgrande!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants