Ruby on rails Rails部署到heroku“检测Rails配置失败”和“/usr/bin/env:'ruby.exe\r”:没有这样的文件或目录

Ruby on rails Rails部署到heroku“检测Rails配置失败”和“/usr/bin/env:'ruby.exe\r”:没有这样的文件或目录,ruby-on-rails,ruby,heroku,Ruby On Rails,Ruby,Heroku,将rails应用程序部署到heroku时收到错误消息 我在一台Windows笔记本电脑上编码 我有两个明显的错误,我认为它们可能是相关的 第一: 远程:/usr/bin/env:'ruby.exe\r':没有这样的文件或目录 然后: 远程:检测rails配置失败 我在Stackoverflow中搜索以寻找解决方案,我尝试应用: 但它不起作用 我还尝试在git bash中执行: dos2unix bin/bundle bin/rake bin/rails 我注意到,如上所述,我将ruby.exe

将rails应用程序部署到heroku时收到错误消息

我在一台Windows笔记本电脑上编码

我有两个明显的错误,我认为它们可能是相关的

第一:

远程:/usr/bin/env:'ruby.exe\r':没有这样的文件或目录

然后:

远程:检测rails配置失败

我在Stackoverflow中搜索以寻找解决方案,我尝试应用:

但它不起作用

我还尝试在git bash中执行:

dos2unix bin/bundle bin/rake bin/rails
我注意到,如上所述,我将ruby.exe更改为ruby并不重要,heroku仍在部署ruby.exe\r\n

这是我第二次在heroku部署Rails项目,第一次没有任何问题,第二次克隆项目并将其用作模板,使用不同的git存储库

谢谢

更新2:

我可以使用heroku local毫无问题地运行它,所以我不确定错误的原因

编辑3

我应用了这两个答案:

现在: 'remote:/usr/bin/env:'ruby.exe\r':没有这样的文件或目录'

不再出现了

仍然无法获取rails配置。以下是日志:

(erb):12:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/erb.rb:876:in `eval'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/erb.rb:876:in `result'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/lib/active_storage/engine.rb:95:in `block (2 levels) in <class:Engine>'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:51:in `each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/app/models/active_storage/blob.rb:235:in `<class:Blob>'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/app/models/active_storage/blob.rb:16:in `<top (required)>'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `load_interlock'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:356:in `require_or_load'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `block in require_or_load'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/active_support.rb:47:in `require_or_load'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:334:in `depend_on'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/active_support.rb:85:in `depend_on'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:246:in `require_dependency'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:477:in `each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:477:in `block in eager_load!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:475:in `each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:475:in `eager_load!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:356:in `eager_load!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:69:in `each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `call'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/config/environment.rb:5:in `<top (required)>'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command/actions.rb:28:in `require_environment!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/commands/runner/runner_command.rb:29:in `perform'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
remote:         from /tmp/build_1139d3f60c8f9853c7eca09a6e6cc23a/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
remote:         from bin/rails:4:in `<main>'

运行bundle update,删除heroku git,然后再次创建heroku应用程序

我通过执行以下操作修复了此问题:

我设置配置:

heroku config:set AWS_ACCESS_KEY_ID=<something>
heroku config:set AWS_SECRET_ACCESS_KEY=<something>
heroku config:set AWS_REGION=<something>
heroku config:set S3_BUCKET_NAME=<something>
因此,我还添加了配置:

heroku config:set RAILS_MASTER_KEY=<something>
做了这件事之后,我又做了一次“git push heroku master”

它成功了

heroku config:set RAILS_MASTER_KEY=<something>