简体   繁体   English

Rails:尝试运行 rails 应用程序时出现冻结错误

[英]Rails: Frozen Error when trying to run rails application

I am running a rails application and when it now shows the below error in console and web application is not loading.我正在运行一个 rails 应用程序,当它现在在控制台中显示以下错误并且 Web 应用程序未加载时。

FrozenError (can't modify frozen fatal): FrozenError(不能修改冻结致命):

Please help as I don't even understand what this is.请帮忙,因为我什至不明白这是什么。 Will provide any further code details if mentioned.如果提到,将提供任何进一步的代码详细信息。

Finally, I found the reason.终于,我找到了原因。 I will explain here the way which I found the solution for the issue so that it may help others who encounter the same error.我将在这里解释我找到问题解决方案的方式,以便它可以帮助遇到相同错误的其他人。

I saw the FrozenError class documentation and found that this was introduced in ruby 2.5.x and later.我看到了 FrozenError 类文档,发现这是在 ruby​​ 2.5.x 及更高版本中引入的。 This is the document FrozenError Doc .这是文档FrozenError Doc I just first upgraded ruby version to latest 2.6.x but this didn't solve the issue.我只是首先将 ruby​​ 版本升级到最新的 2.6.x 但这并没有解决问题。

Fix:使固定:

  • Downgraded the ruby version below 2.5.x to 2.4.x.将 2.5.x 以下的 ruby​​ 版本降级到 2.4.x。
  • Now in 2.4.x, this FrozenError class does not exist.现在在 2.4.x 中,这个 FrozenError 类不存在。
  • I could now see the real error that caused the issue.我现在可以看到导致问题的真正错误。 It was a SystemStackError .这是一个SystemStackError
  • It was caused due a gem in project (wicked_pdf).这是由于项目中的一个 gem (wicked_pdf) 造成的。
  • Removing the gem solved my issue.移除宝石解决了我的问题。

I got the same error when upgrading a Rails app from 4.2.10 to 5.0.将 Rails 应用程序从 4.2.10 升级到 5.0 时,我遇到了同样的错误。 The error only happened with wicked_pdf 2.0.1, a downgrade to wicked_pdf 1.4.0 also made the trick.该错误仅发生在 wicked_pdf 2.0.1 中,降级到 wicked_pdf 1.4.0 也成功了。

For me, it occurred when I tried to find resource.class after running build_resource ,对我来说,它发生在我在运行build_resource后试图找到resource.class

To solve this I removed .class from the resource object为了解决这个问题,我从resource对象中删除了 .class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM