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

Comments

Projects
None yet
@AylwinA

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

This comment has been minimized.

Show comment
Hide comment
@kurtschlatzer

kurtschlatzer Dec 26, 2014

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 commented Dec 26, 2014

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

This comment has been minimized.

Show comment
Hide comment
@kurtschlatzer

kurtschlatzer Dec 26, 2014

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.

kurtschlatzer commented Dec 26, 2014

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

This comment has been minimized.

Show comment
Hide comment
@singularperturbation

singularperturbation Jan 5, 2015

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

singularperturbation commented Jan 5, 2015

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

This comment has been minimized.

Show comment
Hide comment
@pavanpodila

pavanpodila Jan 10, 2015

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

pavanpodila commented Jan 10, 2015

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

@egyptiankarim

This comment has been minimized.

Show comment
Hide comment
@egyptiankarim

egyptiankarim Jan 13, 2015

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.

egyptiankarim commented Jan 13, 2015

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

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr 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.

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

This comment has been minimized.

Show comment
Hide comment
@ymarcus93

ymarcus93 Jan 18, 2015

@egyptiankarim Your solution worked for me.

ymarcus93 commented Jan 18, 2015

@egyptiankarim Your solution worked for me.

@djmtype

This comment has been minimized.

Show comment
Hide comment
@djmtype

djmtype 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.

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

This comment has been minimized.

Show comment
Hide comment
@ymarcus93

ymarcus93 Jan 19, 2015

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

ymarcus93 commented Jan 19, 2015

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

@Behinder

This comment has been minimized.

Show comment
Hide comment
@Behinder

Behinder Jan 19, 2015

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

Behinder commented Jan 19, 2015

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

@EvanHahn

This comment has been minimized.

Show comment
Hide comment
@EvanHahn

EvanHahn Jan 19, 2015

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.

EvanHahn commented Jan 19, 2015

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

This comment has been minimized.

Show comment
Hide comment
@djmtype

djmtype Jan 19, 2015

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

djmtype commented Jan 19, 2015

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

@EvanHahn

This comment has been minimized.

Show comment
Hide comment
@EvanHahn

EvanHahn commented Jan 19, 2015

@djmtype 2.2.0.

@djmtype

This comment has been minimized.

Show comment
Hide comment
@djmtype

djmtype 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

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

This comment has been minimized.

Show comment
Hide comment
@ldexterldesign

ldexterldesign Jan 20, 2015

Hey,

gem cleanup

... fixed it for me

Regards,

ldexterldesign commented Jan 20, 2015

Hey,

gem cleanup

... fixed it for me

Regards,

@djmtype

This comment has been minimized.

Show comment
Hide comment
@djmtype

djmtype 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.

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

This comment has been minimized.

Show comment
Hide comment
@dhcodes

dhcodes 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.

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

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost 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.

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

This comment has been minimized.

Show comment
Hide comment
@brunowego

brunowego Jan 31, 2015

@dhcodes solved.

gem list

psych (2.0.12, 2.0.8)

I removed version 2.0.8 and worked!!

brunowego commented Jan 31, 2015

@dhcodes solved.

gem list

psych (2.0.12, 2.0.8)

I removed version 2.0.8 and worked!!

@FernandoBasso

This comment has been minimized.

Show comment
Hide comment
@FernandoBasso

FernandoBasso Feb 17, 2015

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

FernandoBasso commented Feb 17, 2015

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

@docwhat

This comment has been minimized.

Show comment
Hide comment
@docwhat

docwhat Feb 17, 2015

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

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

Prem Sichanugrist
Add missing require for Psych::Nodes
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 referenced a pull request that will close this issue Feb 25, 2015

Open

Add missing require for Psych::Nodes #74

@sikachu

This comment has been minimized.

Show comment
Hide comment
@sikachu

sikachu 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.

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

This comment has been minimized.

Show comment
Hide comment
@seanriceaz

seanriceaz Mar 13, 2015

@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.

seanriceaz commented Mar 13, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@Thesephi

Thesephi Mar 19, 2015

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

Thesephi commented Mar 19, 2015

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

@sjackman

This comment has been minimized.

Show comment
Hide comment
@sjackman

sjackman Mar 24, 2015

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

sjackman commented Mar 24, 2015

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

@jjnevis

This comment has been minimized.

Show comment
Hide comment
@jjnevis

jjnevis 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

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

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 30, 2015

This:

gem uninstall psych
gem install psych -v 2.0.5

from @EvanHahn worked for me!

ghost commented Mar 30, 2015

This:

gem uninstall psych
gem install psych -v 2.0.5

from @EvanHahn worked for me!

@fidanov

This comment has been minimized.

Show comment
Hide comment
@fidanov

fidanov Apr 20, 2015

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

fidanov commented Apr 20, 2015

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

@happycollision

This comment has been minimized.

Show comment
Hide comment
@happycollision

happycollision May 14, 2015

Thanks @EvanHahn! Your suggestion worked.

happycollision commented May 14, 2015

Thanks @EvanHahn! Your suggestion worked.

@AndresCuervo

This comment has been minimized.

Show comment
Hide comment
@AndresCuervo

AndresCuervo Jun 12, 2015

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

AndresCuervo 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

This comment has been minimized.

Show comment
Hide comment
@Smulligan85

Smulligan85 Jul 1, 2015

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

Smulligan85 commented Jul 1, 2015

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
@sinalpha

This comment has been minimized.

Show comment
Hide comment
@sinalpha

sinalpha 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

sinalpha 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

This comment has been minimized.

Show comment
Hide comment
@zx1986

zx1986 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)

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

This comment has been minimized.

Show comment
Hide comment
@tmccombs

tmccombs Sep 9, 2015

gem cleanup solved it for me as well.

tmccombs commented Sep 9, 2015

gem cleanup solved it for me as well.

@CaptainKraft

This comment has been minimized.

Show comment
Hide comment
@CaptainKraft

CaptainKraft Sep 11, 2015

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

CaptainKraft commented Sep 11, 2015

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

@mattkosoy

This comment has been minimized.

Show comment
Hide comment
@mattkosoy

mattkosoy Sep 14, 2015

gem cleanup worked for me. ✌️

mattkosoy commented Sep 14, 2015

gem cleanup worked for me. ✌️

@Fadhli12

This comment has been minimized.

Show comment
Hide comment
@Fadhli12

Fadhli12 Oct 12, 2015

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

Fadhli12 commented Oct 12, 2015

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

@yonkyunior

This comment has been minimized.

Show comment
Hide comment
@yonkyunior

yonkyunior Oct 27, 2015

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

yonkyunior commented Oct 27, 2015

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

@jwithington

This comment has been minimized.

Show comment
Hide comment
@jwithington

jwithington Dec 2, 2015

@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

jwithington commented Dec 2, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@dikiaap

dikiaap Dec 29, 2015

gem update --system work for me

dikiaap commented Dec 29, 2015

gem update --system work for me

@jcsky

This comment has been minimized.

Show comment
Hide comment
@jcsky

jcsky Jan 6, 2016

gem cleanup work for me

jcsky commented Jan 6, 2016

gem cleanup work for me

@AussieGuy0

This comment has been minimized.

Show comment
Hide comment
@AussieGuy0

AussieGuy0 Feb 17, 2016

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

AussieGuy0 commented Feb 17, 2016

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

@elithrar

This comment has been minimized.

Show comment
Hide comment
@elithrar

elithrar Feb 20, 2016

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.

elithrar commented Feb 20, 2016

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

This comment has been minimized.

Show comment
Hide comment
@deepakmahakale

deepakmahakale Oct 15, 2018

gem uninstall psych

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

deepakmahakale commented Oct 15, 2018

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