【发布时间】:2020-09-22 09:56:32
【问题描述】:
我正在尝试通过 Elastic Beanstalk 在 AWS 上部署 Rails 6 应用程序。
当我运行eb deploy 时,它失败了。
当我查看日志时,我看到了这条消息
2020/06/03 14:19:51.457403 [ERROR] rbenv: version `2.7.0' is not installed (set by /var/app/staging/.ruby-version)
2020/06/03 14:19:51.457439 [ERROR] An error occurred during execution of command [app-deploy] - [stage ruby application]. Stop running the command. Error: install dependencies in Gemfile failed with error Command /bin/sh -c bundle config set --local deployment true failed with error exit status 1. Stderr:rbenv: version `2.7.0' is not installed (set by /var/app/staging/.ruby-version)
但是,当我 eb ssh 并运行 ruby -v 时,我看到我正在运行 ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
所以我将Gemfile 和.ruby-version 更新为ruby 2.7.1 以匹配我的AWS 环境。
当我cd /var/app/staging
和cat .ruby-version
我得到2.7.1
那么为什么这次部署失败了?我在项目中的任何地方都不需要ruby 2.7.0。
我已经确定git push,所以我知道我的 Gemfile 被推送到我的回购。
尝试部署这个 Rails 应用程序我快疯了。
【问题讨论】:
-
尝试将部署策略更改为不可变(在“滚动更新和部署”配置下)。这将每次将您的代码部署在新的服务器上,排除旧文件被读取的可能性。
-
@David 我现在也遇到了同样的问题,请问你是怎么解决的?
-
@littleforest 您的解决方案无法解决问题
-
@chrisgeeq - 我已经在这上面花了 160 多个小时,但我仍然没有弄清楚。我没有放弃,但我只是暂时休息一下。
-
@DavidLee 也有同样的问题,虽然我的问题通过重建环境解决了,你试过了吗?还要确保您的 gemfile 和 ruby-version 引用了正确的版本。
标签: ruby-on-rails amazon-web-services amazon-elastic-beanstalk web-deployment ruby-on-rails-6