1

我正在尝试将我们的 Rails3 应用程序从运行 Ruby 1.9.3 的旧 ElasticBeanstalk 环境迁移到运行 Ruby 2.0 的新环境。

一切似乎工作正常,除了资产预编译 javascript 文件上的“堆栈级别太深”错误(css 编译运行良好)。它在我安装了相同 Gems 的笔记本电脑上运行良好。下面是堆栈跟踪,任何建议都会有所帮助。提前致谢。

    [webapp@ip-10-126-10-155 current]$ rake assets:precompile --trace
    ** Invoke assets:precompile (first_time)
    ** Execute assets:precompile
    /usr/bin/ruby2.0 /usr/local/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets --trace
    ** Invoke assets:precompile:all (first_time)
    ** Execute assets:precompile:all
    ** Invoke assets:precompile:primary (first_time)
    ** Invoke assets:environment (first_time)
    ** Execute assets:environment
    ** Invoke environment (first_time)
    ** Execute environment
    ** Invoke tmp:cache:clear (first_time)
    ** Execute tmp:cache:clear
    ** Execute assets:precompile:primary
    rake aborted!
    SystemStackError: stack level too deep
      (in /var/app/current/app/assets/javascripts/all.js)
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:183
    Tasks: TOP => assets:precompile:primary
    rake aborted!
    Command failed with status (1): [/usr/bin/ruby2.0 /usr/local/bin/rake asset...]
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/file_utils.rb:54:in `block in create_shell_runner'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/file_utils.rb:45:in `call'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/file_utils.rb:45:in `sh'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/file_utils_ext.rb:37:in `sh'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/file_utils.rb:82:in `ruby'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/file_utils_ext.rb:37:in `ruby'
    /usr/local/share/ruby/gems/2.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
    /usr/local/share/ruby/gems/2.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
    /usr/local/share/ruby/gems/2.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:240:in `call'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:240:in `block in execute'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:235:in `each'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:235:in `execute'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
    /usr/share/ruby/2.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:172:in `invoke_with_call_chain'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/task.rb:165:in `invoke'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:150:in `invoke_task'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `each'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `block in top_level'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:115:in `run_with_threads'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:100:in `top_level'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:78:in `block in run'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:176:in `standard_exception_handling'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/lib/rake/application.rb:75:in `run'
    /usr/local/share/ruby/gems/2.0/gems/rake-10.3.1/bin/rake:33:in `<top (required)>'
    /usr/local/bin/rake:23:in `load'
    /usr/local/bin/rake:23:in `<main>'
    Tasks: TOP => assets:precompile
4

1 回答 1

1

我终于找到了原因。那是因为这些代码行是为了支持 Emoji。

module ActiveSupport
  module JSON
    module Encoding
      class << self
        def escape_with_json_gem(string)
          ::JSON.generate([string])[1..-2]
        end
        alias_method_chain :escape, :json_gem
      end 
    end 
  end 
end
于 2014-05-08T02:03:42.080 回答