在本地生产中运行 rails 服务器(InvalidMessage 错误) [英] Running a rails server in production locally (InvalidMessage error)
问题描述
我正在运行 Ruby 2.5.1 和 Rails 5.2.0.我运行了 rails s -e production
,它给出了这个错误:
I'm running Ruby 2.5.1 and Rails 5.2.0. I ran rails s -e production
, and it gives this error:
/home/roy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:206:in `rescue in_decrypt': ActiveSupport::MessageEncryptor::InvalidMessage
(ActiveSupport::MessageEncryptor::InvalidMessage)
我该如何正确执行此操作?
How do I do this properly?
每当我尝试使用
EDITOR="nano --wait" bin/rails credentials:edit
我也意识到我还没有创建生产数据库,所以我尝试使用
Also I realized that I didn't create a production database yet so I tried that using
RAILS_ENV=production bundle exec rails db:reset
(我知道 db:reset 有点多余,但它应该可以尝试创建、迁移和播种服务器)
(I know db:reset is a bit redundant but it should work trying to create, migrate and seed a server)
遗憾的是我遇到了同样的错误(InvalidMessage 错误)
Sadly I get the same kind of error (InvalidMessage error)
Unsupported rails environment for compass
rake aborted!
ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
/home/roy/apps/myappname/config/environment.rb:5:in `<main>'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
Caused by:
OpenSSL::Cipher::CipherError:
/home/roy/apps/myappname/config/environment.rb:5:in `<main>'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:create => db:load_config => environment
推荐答案
好的,我终于搞定了.
我只是删除了我的 master.key
和 credentials.yml.enc
文件,然后运行
I simply deleted my master.key
and credentials.yml.enc
files and then ran
bin/rails credentials:edit
创建了新文件.之后一切正常.
Which created new files. After that everything worked fine.
我真的不明白为什么它有效.任何人都可以对此做出很好的解释吗?
I don't really understand why it works though. Can anyone give a good explanation for this?
这篇关于在本地生产中运行 rails 服务器(InvalidMessage 错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!