运行Rails 2.3.2应用程序时rake的Psych语法错误

时间:2016-03-30 09:08:52

标签: ruby-on-rails

我正在使用Ruby版本1.9.3p551(在RVM上)的Rails 2.3.2应用程序。当我试图运行这个旧的应用程序时,我得到了一个' Psych语法错误'那是当我运行rake db:migrate或rake -v或任何其他时,我收到错误。请帮我。我得到的错误日志是:

myuser@iam:~/Desktop/practice/Application$ rake -v
rake aborted!
Psych::SyntaxError: (<unknown>): did not find expected node content while parsing a flow node at line 18 column 14
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:189:in `load_yml'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:176:in `load_file'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:13:in `block in load_translations'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:13:in `each'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:13:in `load_translations'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:85:in `init_translations'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:74:in `available_locales'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb:50:in `available_locales'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:215:in `valid_locale?'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:234:in `split'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:113:in `initialize'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:87:in `new'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:87:in `create_template'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:82:in `block in templates_in_path'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:81:in `each'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:81:in `templates_in_path'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:64:in `load!'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:49:in `block in new_and_loaded'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/core_ext/object/misc.rb:39:in `returning'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_view/template.rb:48:in `new_and_loaded'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/rescue.rb:41:in `<module:Rescue>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/rescue.rb:17:in `<module:ActionController>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/rescue.rb:1:in `<top (required)>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/base.rb:1406:in `block in <module:ActionController>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/base.rb:1405:in `class_eval'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/base.rb:1405:in `<module:ActionController>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/actionpack-2.3.2/lib/action_controller/base.rb:3:in `<top (required)>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/initializer.rb:446:in `initialize_framework_caches'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/initializer.rb:144:in `process'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/initializer.rb:113:in `run'
/home/myuser/Desktop/practice/Application/config/environment.rb:9:in `<top (required)>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `block in require'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/tasks/misc.rake:4:in `block in <top (required)>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/tasks/testing.rake:45:in `block (2 levels) in <top (required)>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/tasks/testing.rake:43:in `collect'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/gems/rails-2.3.2/lib/tasks/testing.rake:43:in `block in <top (required)>'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
/home/myuser/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => test:units => db:test:prepare => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)

1 个答案:

答案 0 :(得分:0)

它位于Task内的其中一个本地化文件中看起来像语法错误。跟踪没有命名文件 - 您可以尝试使用config/locales运行任务,或者您可以尝试解析每个文件:

--trace

您可以将其放在rails root directry中的文件中,然后使用require 'yaml' Dir.glob("config/locales/*.yml").each do |f| begin YAML.load(File.read(f)) rescue Psych::SyntaxError => e puts "YAML syntax error in: #{f}" puts e.message end end 或通过将其粘贴到普通ruby locale_linter.rb控制台中来运行。

输出应指向违规文件:

irb