升级到OS X 10.14后,我的rails应用程序不再起作用。我试图找出原因。我在试图将@secret分配给cipher.key的行上收到了active_support_(5.0.0.1)_lib / active_support / message_encryptor.rb引发的异常。例外情况是密钥必须为32个字节。
在我尝试解决的这一点上,我想知道为什么从应用程序目录运行捆绑安装报告说它正在安装activesupport 5.0.7.2,但是当应用程序运行(通过puma)时,activesupport中的代码引发了异常5.0.0.1。 rvm是我的ruby版本管理器。它报告说它正在运行ruby 2.4.1(这是我在升级之前安装的版本)。我认为OS X 10.14附带2.3.7,但这似乎不是问题。 Rails的版本为5.0.0.1。 我以为我会尝试将Rails更新到5.0.7.2。我阅读了“升级Ruby on Rails”页面,并修改了我的Gemfile以指定rails〜= 5.0.7(过去是〜> 5.0.2),然后运行rake rails :: update产生了一条错误消息:“您已激活rake 12.3。 .2,但您的Gemfile需要rake 11.3.0。 我在Gemfile中找不到对rake的引用。该错误由boot.rb在必需的“ bundler / setup”上抛出。
我希望有人能够告诉我如何将rails更新到最新版本,希望这样做后,我的最初问题将消失。 服务器日志中的完整堆栈:
ArgumentError (key must be 32 bytes):
activesupport (5.0.0.1) lib/active_support/message_encryptor.rb:72:in `key='
activesupport (5.0.0.1) lib/active_support/message_encryptor.rb:72:in `_encrypt'
activesupport (5.0.0.1) lib/active_support/message_encryptor.rb:58:in `encrypt_and_sign'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:592:in `commit'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:465:in `[]='
actionpack (5.0.0.1) lib/action_dispatch/middleware/session/cookie_store.rb:117:in `set_cookie'
rack (2.0.1) lib/rack/session/abstract/id.rb:353:in `commit_session'
rack (2.0.1) lib/rack/session/abstract/id.rb:224:in `context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.0.0.1) lib/active_record/migration.rb:552:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.4.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.4.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.4.0) lib/web_console/middleware.rb:18:in `catch'
web-console (3.4.0) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.0.1) > lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
Rendering /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (1.8ms)
Rendering /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.1ms)
Rendering /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.6ms)
Rendered /Users/jboss/.rvm/gems/ruby-2.4.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (84.1ms)
Started PUT "/__web_console/repl_sessions/2b97efeccea3498fd96b79db013b3da9" for 127.0.0.1 at 2019-03-26 10:59:35 -0400
Started PUT "/__web_console/repl_sessions/2b97efeccea3498fd96b79db013b3da9" for 127.0.0.1 at 2019-03-26 10:59:36 -0400
来自Gemfile.lock:
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
globalid (>= 0.3.6)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activesupport (5.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
.
.
.
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.2)
答案 0 :(得分:0)
从堆栈跟踪来看,它使用的是正确的红宝石版本,看起来不错。看起来好像是您的gemfile.lock在说您被锁定在其他gem中,为什么它不运行它们? (activesupport 5.0.0.1而不是5.0.7.2)
我个人认为您需要捆绑更新/和/或删除该锁,然后再次运行捆绑安装。或查找麻烦制造者的宝石并进行更新。也许甚至将ruby '2.4.1'
放入您的gemfile中,也可能会使您的捆绑软件锁定,以确保它使用的是正确的红宝石版本。一件事可能会帮助您找到正在使用该旧耙子的宝石:
gem dependency rake --reverse-dependencies
How do I find out which gem has a specific dependency?
然后搜索rake 11.3.0,看看它在使用什么。
您实际上已经讨论了一个旧错误: https://github.com/rails/rails/issues/25185 据推测是由以下方式解决的: https://github.com/rails/rails/pull/25192
问题是,为什么升级后您的导轨仍像运行5.0.0.1一样运行?我不知道您的2.4.1 rvm gems文件是否具有新的升级的gems,或者您的捆绑程序是否以某种方式将它们安装到其他版本中。也许还检查bundle show activesupport
,以查看将跟踪引回到rvm 2.4.1文件夹的情况。
这个人可能为您回答了他自己的问题: Rails 5 production error activesupport
因此,也许完全升级到更高的轨道可能会节省您的时间。
希望其中一些能让您走上正确的道路!