Rails: cannot load such file — safe_yaml/transform

2019-08-08 17:13发布

问题:

My rails app is not running and i am getting error:

  cannot load such file -- safe_yaml/transform/to_symbol (LoadError)

I dont know why this error is coming. When i remove gem 'safe_yaml', it gives error:

 Could not find safe_yaml-0.9.4 in any of the sources (Bundler::GemNotFound)

When i install gem safe_yaml-0.9.4, it gives:

 cannot load such file -- safe_yaml/transform/to_symbol (LoadError)

Can anybody tell how to solve this?

Thanks

回答1:

There was problem with safe_yaml version.

I have rails-admin 0.4.9. For this, safe_yaml 0.6.3 is required where rails_admin 0.4.9 installs safe_yaml 0.9.4.

So i included safe_yaml 0.6.3 in my gemfile separately and removed safe_yaml 0.6.4.

And everything worked!!

Thank everyone for help.



回答2:

There is a bug in the 0.9.4 release of safe_yaml. The file lib/safe_yaml/transform/to_symbol.rb has permissions of 640 instead of 644. If your gem is installed as root, this will cause the file to be unreadable by anything not root. Besides falling back to 0.9.3 (I think that is what the prior poster really meant instead of 0.6.3), you could chmod the file to 644 yourself and you can get past this bug.