我正在运行Ruby 2.5.1和Rails 5.2.0。我运行了rails s -e production
,它给出了这个错误:
/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)
如何正确执行此操作?
编辑:
每当我尝试使用来编辑凭据文件时,都会出现相同的错误
EDITOR="nano --wait" bin/rails credentials:edit
我也意识到我还没有创建生产数据库,所以我尝试使用
RAILS_ENV=production bundle exec rails db:reset
(我知道db:reset有点多余,但是在尝试创建,迁移和设置服务器种子时应该可以使用)
可悲的是,我得到了同样的错误(InvalidMessage错误)
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
文件,然后运行
bin/rails credentials:edit
哪个创建了新文件。之后,一切正常。
我真的不明白为什么它起作用。谁能对此做出很好的解释?
关于ruby-on-rails - 在本地生产环境中运行Rails服务器(InvalidMessage错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50102639/