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

uninitialized constant Psych::Nodes (NameError) #72

Open
AylwinA opened this issue Dec 16, 2014 · 44 comments · May be fixed by #74
Open

uninitialized constant Psych::Nodes (NameError) #72

AylwinA opened this issue Dec 16, 2014 · 44 comments · May be fixed by #74

Comments

@AylwinA
Copy link

AylwinA commented Dec 16, 2014

using windows 8 have this uninitialized constant problem with safe_yaml => safe_yaml-1.0.4/lib/safe_yaml/psych_resolver.rb:4:in <class:PsychResolver>' *unless* I run the command with bundle exec before the command. I've triedgem update` and nothing changed.

Any ideas?

@kurtschlatzer
Copy link

Having same problem on OSX Yosemite:

/.rvm/gems/ruby-2.1.5/gems/safe_yaml-1.0.4/lib/safe_yaml/psych_resolver.rb:4:in `class:PsychResolver': uninitialized constant Psych::Nodes (NameError)

@kurtschlatzer
Copy link

I noticed this in the safe_yaml readme:

When you require the safe_yaml gem in your project, YAML.load is patched to accept one additional (optional) options parameter.
This changes the method signature as follows:
for Syck and Psych prior to Ruby 1.9.3: YAML.load(yaml, options={})
for Psych in 1.9.3 and later: YAML.load(yaml, filename=nil, options={})

I'm going to explore Jekyll to see how it's using safe_yaml in the latest release.

@singularperturbation
Copy link

I'm affected by this as well with Jekyll 2.5.3 & safe_yaml 1.0.4, but not with Jekyll 2.4.0 & safe_yaml 1.0.0. (MRI Ruby 2.2.0)

Strangely enough, this looks like it could be a problem with Psych itself? I attached pry in psych_resolver.rb, did a show-source on Psych, and it looks like it's being overridden or Psych::Nodes is not being exported after loading psych in psych_handler.rb.

https://gist.github.com/singularperturbation/ec150255a8be199f8e80

@pavanpodila
Copy link

Having the same problem: Jekyll 2.5.3, safe_yaml 1.0.4, Ruby 2.2 and Psych 2.0.8

@egyptiankarim
Copy link

I'm finding I've got to back down to Psych 2.0.5 with Jekyll 2.5.3 and safe_yaml 1.0.4, in order to solve the issue.

@parkr
Copy link

parkr commented Jan 13, 2015

I think psych comes with Ruby & is compiled with a specific Ruby in mind, so you would need to upgrade Ruby to upgrade Psych. C extensions/dylib's etc.

@ymarcus93
Copy link

@egyptiankarim Your solution worked for me.

@djmtype
Copy link

djmtype commented Jan 19, 2015

@egyptiankarim I've had Psych 2.0.5, Jekyll 2.5.3 and safe_yaml 1.0.4 installed all along, so I don't think this is the solution for me since I received the error with these versions installed.

Also, I'm running Ruby 2.1.0 which installs from running gem update --system on a Mac.

Now, I've updated all my gems and cleaned out old ones. Psych was updated to 2.0.10. There was no update to safe_yaml. Anyway, the error still persists.

@ymarcus93
Copy link

@djmtype Try using Ruby 2.2.0 with the correct versions for Psych, Jekyll, and safe_yaml, and see if the problem persists.

@Behinder
Copy link

The same problem, all recent version of psych Jekyll and safeyaml and error exists

@EvanHahn
Copy link

Had the same problem. Fixed this by using Psych 2.0.5:

gem uninstall psych
gem install psych -v 2.0.5

Not sure if that was the most elegant solution.

@djmtype
Copy link

djmtype commented Jan 19, 2015

@EvanHahn That didn't do it for me. What Ruby version do you have installed?

@EvanHahn
Copy link

@djmtype 2.2.0.

@djmtype
Copy link

djmtype commented Jan 19, 2015

@EvanHahn Thanks. Ok, I'm still on Ruby v2.1.0.

The culprit might be psych…

gem list reveals psych (2.0.5,2.0.2) So, I ran, sudo gem uninstall psych -v 2.0.2 but it returned an error:
ERROR: While executing gem ... (Gem::InstallError) gem "psych" cannot be uninstalled because it is a default gem

But, according to gem-list v2.0.2 follows after v2.0.5 in the list. Is v2.0.5 not the default version the system is using? [Confused.]

So, I uninstalled v2.0.5 because it won't allow me to uninstall v2.0.2.

Jekyll works! thus far

@ldexterldesign
Copy link

Hey,

gem cleanup

... fixed it for me

Regards,

@djmtype
Copy link

djmtype commented Jan 20, 2015

Running gem cleanup never resolved the issue of removing psych 2.0.2 when I also had 2.0.10 installed. That's the problem. It still leaves 2.0.2 installed.

Running gem update psych will not update psych from 2.0.2 to 2.0.10. Instead, it will install v 2.0.10 in addition.
psych (2.0.10, 2.0.2)

This is why jekyll is failing with Ruby 2.1.0. Psych 2.0.10 doesn't seem compatible with this version of Ruby or another gem.

Running gem uninstall psych automatically removes the latest version, 2.0.10. The oddity in that is I'm usually prompt to which version I'd like to remove if there are multiple versions of the same gem installed.

@dhcodes
Copy link

dhcodes commented Jan 21, 2015

To piggyback, gem list for me showed psych (2.0.5, 2.0.0).

I removed 2.0.5 (seems to be the problem) with sudo gem uninstall psych -v 2.0.5

I was then able to install Jekyll correctly with sudo jekyll new .

Hope that helps someone.

@ghost
Copy link

ghost commented Jan 26, 2015

What are the correct gem versions of Psych, Jekyll and Safe_yaml to work with ruby 2.2.0? Ive tried various versions of all gems but still get the same error.

@brunowego
Copy link

@dhcodes solved.

gem list

psych (2.0.12, 2.0.8)

I removed version 2.0.8 and worked!!

@FernandoBasso
Copy link

Uninstalling psych-2.0.12 and keeping only psych-2.0.5 solved the problem for me.

@docwhat
Copy link

docwhat commented Feb 17, 2015

Removing all but one of the versions of psych seems like the wrong solution. Why does safe_yaml have this problem?

sikachu pushed a commit to sikachu/safe_yaml that referenced this issue Feb 25, 2015
This resolves an issue where you would get uninitialized constant
Psych::Nodes (NameError) when running with newer version of Psych.

Fixes dtao#72
@sikachu sikachu linked a pull request Feb 25, 2015 that will close this issue
@sikachu
Copy link

sikachu commented Feb 25, 2015

I've submitted #74 which adds require "psych/nodes" on the file that causes the issue. That hopefully should solve the problem.

I have a feeling that there's something going on with the load order, and that's why you're not seeing it with psych <= 2.0.5. I didn't spend time to debug it, because explicitly requiring stuff before use feels like the right fix to me anyway.

@seanriceaz
Copy link

@ldexterldesign That solution: gem cleanup worked for me as well. Not sure why... I'm running ruby 2.2.0 on a windows box even.

@Thesephi
Copy link

@ldexterldesign @seanriceaz I also confirm the gem cleanup works. I'm on Mac Yosemite, rbenv with ruby 2.2.0

@sjackman
Copy link

gem cleanup didn't work for me. I resolved this issue by removing all installed gems followed by gem install github-pages.

@jjnevis
Copy link

jjnevis commented Mar 27, 2015

'bundle exec' worked for me...

-> jekyll serve # I get the error

-> bundle exec jekyll serve # no error :) happy days

you can put this in your .zshrc (or similar) to make it happen automatically:

# Bundle exec commands
bundle_commands=( rake spec rspec cucumber cap watchr rails rackup jekyll )
function run_bundler_cmd () {
    if [ -e ./Gemfile ]; then
        echo "bundle exec $@"
        bundle exec $@
    else
        echo "$@"
        $@
    fi
}
for cmd in $bundle_commands
do
    alias $cmd="run_bundler_cmd $cmd"
done

@ghost
Copy link

ghost commented Mar 30, 2015

This:

gem uninstall psych
gem install psych -v 2.0.5

from @EvanHahn worked for me!

@fidanov
Copy link

fidanov commented Apr 20, 2015

Doing gem update --system and then gem update solved the problem for me.

@happycollision
Copy link

Thanks @EvanHahn! Your suggestion worked.

@cwervo
Copy link

cwervo commented Jun 12, 2015

@ldexterldesign gem cleanup worked for me on Yosemite 10.10.3 with RVM with Ruby 2.1.2 (default).

lepistone added a commit to lepistone/lepistone.github.io that referenced this issue Jun 29, 2015
@Smulligan85
Copy link

I had this problem with Ruby 2.2.0 and Jekyll (2.0.12 2.0.8) installed. Uninstalling 2.0.12 worked for me. Is it possible that having a version of Psych other than the default version associated with the Ruby version is causing an error?

gem uninstall psych -v 2.0.12

@datewu
Copy link

datewu commented Jul 11, 2015

Thanks to @djmtype

gem update --system works on me.

gem version updated frome 2.4.5 to 2.4.8.
ruby version 2.2.2; safe_yam-1.0.4

@zx1986
Copy link

zx1986 commented Jul 12, 2015

gem cleanup works for me.

jekyll (2.5.3)
jekyll-coffeescript (1.0.1)
jekyll-gist (1.2.1)
jekyll-paginate (1.1.0)
jekyll-sass-converter (1.3.0)
jekyll-watch (1.2.1)
safe_yaml (1.0.4)
psych (2.0.13, 2.0.8)

@tmccombs
Copy link

tmccombs commented Sep 9, 2015

gem cleanup solved it for me as well.

@CaptainKraft
Copy link

gem cleanup did not work for me; however, gem uninstall psych removed one of the two installed packages and now it works.

@mattkosoy
Copy link

gem cleanup worked for me. ✌️

@Fadhli12
Copy link

psych -v 2.0.5 work for me, thanks for the solution

@yonkyunior
Copy link

thanks! its work.
after i run 'gem update', that's trigger this mess for me.
i do 'gem cleanup'
and 'gem uninstall psych'

@jwithington
Copy link

@sjackman your solution worked for me, thanks! 👍

The different mix of 'gem update,' 'gem cleanup,' and 'gem uninstall psych' didn't fix it.

OS 10.11.1 over here

@dikiaap
Copy link

dikiaap commented Dec 29, 2015

gem update --system work for me

@jcsky
Copy link

jcsky commented Jan 6, 2016

gem cleanup work for me

@AussieGuy0
Copy link

I had the same error after running gem update, running gem cleanup fixed the problem.

@elithrar
Copy link

Running gem cleanup only works until your next gem update. It's a temporary fix.

I'm still suffering from this on Ruby 2.2.3 with:

  • psych (2.0.17, 2.0.8)
  • safe_yaml (1.0.4)
  • jekyll (3.1.2, 3.0.1)

Forcing psych 2.0.8 is a workaround.

ota42y pushed a commit to ota42y/safe_yaml that referenced this issue Aug 14, 2017
@deepakmahakale
Copy link

gem uninstall psych

ERROR: While executing gem ... (Gem::InstallError)
gem "psych" cannot be uninstalled because it is a default gem

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 a pull request may close this issue.