Rake aborted! Can't convert Hash into String?

Go To StackoverFlow.com

1

How do I better debug this message? The trace shows 3 lines from one of my files - application.rb:

18 module CustomApp
19   class Application < Rails::Application
...
49 # Enable the asset pipeline

Is there a way to find out exactly which file is throwing this error?

The last trace:

/home/user/.rvm/gems/ruby-1.9.3-p0/gems/figaro-0.2.0/lib/figaro/railtie.rb:8:in `update'

I feel like I've hit a brick wall..for that reason, although I'm anxious to fix this error, I'm more anxious to find out how to better debug these messages? Surely something like "Can't convert Hash into String in somefile.rb:112" would be easily handled?

2012-04-05 19:23
by Damien Roche
That's not the latest version of that gem, perhaps try updating it - Andrew Marshall 2012-04-05 19:26
Just updated with bundler - "Installing figaro (0.2.0)". Same error. Updated original question with new trace - Damien Roche 2012-04-05 19:29
It looks like it might be having trouble with your config/application.yml file. Did you alter that in any way or is it not formatted correctly? (I'm making this guess based on reading the line of code reported in your 'last trace. - Charles Caldwell 2012-04-05 19:42
I'm getting the same with Rake v0.9.2, but not with v10. So an upgrade definitely helped me. Please make sure it wasn't coming from rake itself (and that trace being a red herring - inger 2013-03-05 22:14


1

To learn about ruby-debug: http://bashdb.sourceforge.net/ruby-debug.html

To learn about debugging Rails: http://guides.rubyonrails.org/debugging_rails_applications.html

The error is coming from this file:

lib/figaro/railtie.rb line 8

The code block in that file:

path = Rails.root.join("config/application.yml")
ENV.update(YAML.load(File.read(path)) || {}) if File.exist?(path)

One way to troubleshoot is to use ruby-debug:

gem install ruby-debug

And edit that file to make it show better errors:

path = Rails.root.join("config/application.yml")
if File.exist?(path)
   debugger  
   f = File.read(path)  
   y = YAML.load(f)
   ENV.update(y || {})
end
2012-04-05 19:49
by joelparkerhenderson
For Ruby 2.0, also see the byebug gem, which is new and fast - joelparkerhenderson 2013-12-12 06:58
Ads