ruby-1.9.2-p290 fails to start rails rack application (psych fails) #2104

Closed
radosch opened this Issue Jul 16, 2011 · 28 comments

Projects

None yet

10 participants

radosch commented Jul 16, 2011

when I try to start the application I get this
Tried with webrick, mongrel, pow, every server the same error.
on ruby-1.9.2-p-180 it works like a charm.

/Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:196:in `merge!': can't convert nil into Hash (TypeError)
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:196:in `block in visit_Psych_Nodes_Mapping'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each_slice'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `visit_Psych_Nodes_Mapping'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:205:in `block in visit_Psych_Nodes_Mapping'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `each_slice'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:190:in `visit_Psych_Nodes_Mapping'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/nodes/node.rb:25:in `to_ruby'
    from /Users/rafael/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:107:in `load'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/application/configuration.rb:95:in `database_configuration'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activerecord-3.1.0.rc4/lib/active_record/railtie.rb:68:in `block (2 levels) in <class:Railtie>'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activerecord-3.1.0.rc4/lib/active_record/railtie.rb:67:in `block in <class:Railtie>'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:25:in `instance_exec'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:25:in `run'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:49:in `each'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:49:in `run_initializers'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/application.rb:96:in `initialize!'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/rafael/Sites/myApp/config/environment.rb:5:in `<top (required)>'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `block in require'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in `require'
    from /Users/rafael/Sites/myApp/config.ru:6:in `block in <main>'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/rafael/Sites/myApp/config.ru:1:in `new'
    from /Users/rafael/Sites/myApp/config.ru:1:in `<main>'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/builder.rb:40:in `eval'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/server.rb:200:in `app'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:46:in `app'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/rack-1.3.1/lib/rack/server.rb:252:in `start'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:70:in `start'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/commands.rb:54:in `block in <top (required)>'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `tap'
    from /Users/rafael/.rvm/gems/ruby-1.9.2-p290@rails-3-1/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

GEMSET

abstract (1.0.0)
actionmailer (3.1.0.rc4)
actionpack (3.1.0.rc4)
activemodel (3.1.0.rc4)
activerecord (3.1.0.rc4)
activeresource (3.1.0.rc4)
activesupport (3.1.0.rc4, 3.0.7)
acts-as-taggable-on (2.0.6)
annotate (2.4.0)
ansi (1.3.0)
archive-tar-minitar (0.5.2)
arel (2.1.3)
arrayfields (4.7.4)
attr_accessible_block (0.2.2)
bcrypt-ruby (2.1.4)
builder (3.0.0)
bundler (1.0.15, 1.0.13)
cancan (1.5.0.beta1)
capistrano (2.6.0)
capistrano-ext (1.2.1)
capybara (1.0.0)
cells (3.6.3)
cgi_multipart_eof_fix (2.5.0)
childprocess (0.1.9)
chronic (0.3.0)
chunky_png (1.2.0)
churn (0.0.13)
cocaine (0.1.0)
coderay (0.9.8)
coffee-script (2.2.0)
coffee-script-source (1.1.1)
colored (1.2)
columnize (0.3.4)
compass (0.11.5)
configuration (1.3.1, 1.2.0)
css3buttons (0.9.5)
cucumber (1.0.1)
cucumber-rails (1.0.2)
daemon_controller (0.2.6)
daemons (1.1.3, 1.0.10)
database_cleaner (0.6.7)
devise (1.4.2)
diff-lcs (1.1.2)
email_spec (1.2.1)
erubis (2.7.0)
execjs (1.2.0)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
faker (0.9.5)
fastthread (1.0.7)
fattr (2.2.0)
ffi (1.0.9)
flay (1.4.2)
flog (2.5.1)
formtastic (1.2.4)
fssm (0.2.7)
gem_plugin (0.2.3)
gherkin (2.4.5)
ginger (1.2.1)
gravtastic (3.1.0)
haml (3.1.2)
haml-rails (0.3.4)
highline (1.6.2)
hike (1.1.0)
hirb (0.4.5)
hpricot (0.8.4)
i18n (0.6.0)
jquery-rails (1.0.12)
json (1.5.3)
json_pure (1.5.3)
kaminari (0.12.4)
launchy (0.4.0)
libv8 (3.3.10.2 x86_64-darwin-10)
linecache19 (0.5.12)
mail (2.3.0)
main (4.6.0)
make_voteable (0.0.2)
map (4.2.0)
method_source (0.4.1)
metric_fu (2.1.1)
metrical (0.0.5)
mime-types (1.16)
mongrel (1.2.0.pre2)
multi_json (1.0.3)
mysql2 (0.3.5, 0.3.2)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.1.4)
net-ssh-gateway (1.1.0)
nokogiri (1.5.0)
orm_adapter (0.0.5)
paper_trail (2.2.8)
paperclip (2.3.11)
passenger (3.0.7)
polyglot (0.3.1)
populator (1.0.0)
powder (0.1.4)
pry (0.8.3)
rack (1.3.1)
rack-cache (1.0.2)
rack-mount (0.8.1)
rack-ssl (1.3.2)
rack-test (0.6.0)
rails (3.1.0.rc4)
rails-footnotes (3.7.4)
rails3_acts_as_paranoid (0.0.8)
rails_best_practices (0.10.0)
railties (3.1.0.rc4)
rake (0.9.2, 0.9.1, 0.8.7)
rcov (0.9.9)
rdoc (3.8)
recaptcha (0.3.1)
RedCloth (4.2.7)
redis (2.2.1)
redis-friendships (0.2)
reek (1.2.8)
rest-client (1.6.1)
riddle (1.3.3)
roodi (2.1.0)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
ruby-debug-base19 (0.11.25)
ruby-debug-base19x (0.11.26)
ruby-debug-ide (0.4.17.beta3)
ruby-debug19 (0.11.6)
ruby-progressbar (0.0.10)
ruby2ruby (1.2.5)
ruby_core_source (0.1.5)
ruby_parser (2.0.6)
rubyzip (0.9.4)
Saikuro (1.1.0)
sass (3.1.4)
sass-rails (3.1.0.rc.4)
selenium-webdriver (0.2.2)
sentient_user (0.3.2)
sexp_processor (3.0.5)
showoff-io (0.3.1)
simple-navigation (3.3.4)
simplecov (0.4.2)
simplecov-html (0.4.5)
slop (1.6.0)
spork (0.9.0.rc9)
sprockets (2.0.0.beta.10)
sqlite3 (1.3.3)
syntax (1.0.0)
term-ansicolor (1.0.5)
therubyracer (0.9.2)
thinking-sphinx (2.0.5)
thor (0.14.6)
tilt (1.3.2)
treetop (1.4.9)
turn (0.8.2)
tzinfo (0.3.29)
uglifier (1.0.0)
warden (1.0.4)
watchr (0.7)
will_paginate (3.0.pre2)
xpath (0.1.4)
Contributor

Seeing the stacktrace, this would seem to be a psych error.

radosch commented Jul 16, 2011

put this in boot.rb to have a workaround

require 'yaml'
YAML::ENGINE.yamler= 'syck'

saves the day, but is that really psych problem?
changes to syck, but I have the impression it is much slower then before.

whats the difference between psych gem and the ruby native lib, is there a way to take the gem lib?

Owner

I'm seeing this too in rails 3.0.9
Looks like ruby-1.9.2-p290 uses psyck 1.0.0. (at least in my rvm install of it)
Psych 1.2.0 has this fixed : ruby/psych#20

radosch commented Jul 16, 2011

do you know, how to override, not taking ruby's psych but the gem?

Am 16.07.2011 um 18:50 schrieb gberenfield:

I'm seeing this too in rails 3.0.9
Looks like ruby-1.9.2-p290 uses psyck 1.0.0. (at least in my rvm install of it)
Psych 1.2.0 has this fixed : ruby/psych#20

Reply to this email directly or view it on GitHub:
#2104 (comment)

I don't know how on the override, but am willing to try.

I have noticed that a new rails app under 1.9.2-p290 works fine. And some of my other apps seem to run fine too.
My current app that blew up does use thinking_sphinx and I think it's when it tries to start a sphinx instance that the problem occurs.

I get the same error just doing a 'rake thinking_sphinx:start' to start a sphinx instance.
https://gist.github.com/1086603

Contributor

Specify psych 1.2 in your Gemfile, it should work like a charm.

It appears to not be working so well. https://gist.github.com/1086964
Note the warnings at the very top.

Owner

@gberenfield can you post your database configuration yaml file?

Ok I saw this and thought it might be relevant so built ruby-1.9.2-p290 myself from source (no rvm) and installed to a ~/rube directory to isolate.

It needed a libyaml so installed 0.1.3 from homebrew and I still had psych @ 1.2.0 in my Gemfile.
It gave: psych/visitors/to_ruby.rb:218:in `merge!': can't convert nil into Hash (TypeError)

I removed psych from my Gemfile, rebundled and it ran fine.

Psych doesn't like lines 23-24 from https://gist.github.com/1087067 in my database.yml file.
This gist shoes an irb session testing it out and replacing with Syck

Owner

Merge keys in Psych are case sensitive. It looks like you define a TEST key, then use it as test:

test: &TEST
  adapter: mysql2

cucumber:
  <<: *test

Try changing it to this:

test: &TEST
  adapter: mysql2

cucumber:
  <<: *TEST

I want to keep merge keys case sensitive in Psych. I will improve the exception messages though!

This isn't a bug in rails, so I'm going to close the ticket. :-)

@tenderlove tenderlove closed this Jul 18, 2011
Contributor

I do not know if this is related, but i have just upgraded to ruby 1.9.2-p290 and cannot run my rails application, and i've found this issue by searching for "can't convert nil into Hash" in google.
The problem in my application is caused by the t translation method, it uses YAML localization files.
The controller displays the "TypeError" in the browser:

can't convert nil into Hash

If i use a non-localised string in that place (without t), there is no errors until the next t in the ERB view.

Alexey.

Contributor

Adding

require 'yaml'
YAML::ENGINE.yamler = 'syck'

to boot.rb solved the problem for me.
Is there a better way? Is this a bug?

All variables in my YAML localization files are lower-case.

Owner

Can you post the yaml file that is failing?

Aaron Patterson
http://tenderlovemaking.com/

On Jul 19, 2011, at 10:17 AM, alexeymuranovreply@reply.github.com wrote:

Adding

require 'yaml'
YAML::ENGINE.yamler = 'syck'

to boot.rb solved the problem for me.
Is there a better way? Is this a bug?

All variables in my YAML localization files are lower-case.

Reply to this email directly or view it on GitHub:
#2104 (comment)

Contributor

Here is the whole file:
https://gist.github.com/1093175

I will try to come up with a shorter example.

Thanks.

Contributor

In fact, even if fr.yml consists only of

fr:
  application_layout:
    navigation_links:
      monitor: "Écran de contrôle"

the line t("application_layout.navigation_links.monitor") still produces an error in the view.
So i think i will remove the gist...

Contributor

Shouldn't this issue be marked open?

@spastorino spastorino reopened this Jul 23, 2011
Owner

So you're not having an issue with YAML parsing anymore, but an issue with I18N lookup?

@spastorino spastorino closed this Jul 23, 2011
Owner

sorry for closing and opening the issue, I will leave this up to @tenderlove :)

Contributor

Sorry, i do not know what the issue is with, but i had to add YAML::ENGINE.yamler = 'syck' to make my application work...

Owner

are you actually getting parse errors when using Psych, or is it i18n errors? Can you post the YAML file that you're having issues with?

Contributor

I have figured that out: i used a variable in YAML before defining it.
For some reason i believed that a very simple nested YAML failed.
Sorry about that.
Thanks.

schorsch commented Dec 3, 2011

had the same issue with ruby-1.9.2-p290 when parsing a yaml file with something like this in it:

    cucumber: &CUCUMBER
    <<: *TEST

after killing it was read.

Changing the database.yml to this:

 test: &TEST
 adapter: mysql2

 cucumber:
 <<: *TEST

as suggested by @tenderlove worked for me.

avocade commented Mar 23, 2012

@porsamini Confirmed works.

gryphis commented Apr 6, 2012

Hi,
I use ruby-1.9.3-p125 with rails-3.2.3 and had the same problem. I looked at the code in psych/visitors/to_ruby.rb. In

  private
  def revive_hash hash, o
      ... 
      if key == '<<' 
        case v
        when Nodes::Alias
          hash.merge! accept(v)

The error message "in `merge!': can't convert nil into Hash (TypeError)" is caused by the last line, accept(v) delivers nil, this cannot merged into the hash.
I changed the if... to

      if key == '<<' and accept(v)

and my things work well.

Hope that helps you,
cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment