繁体   English   中英

在 Rails 6 上为 Ruby 创建弹性 beanstalk 环境时遇到问题(rvm、rbenv、.ruby 版本问题)

[英]Trouble creating elastic beanstalk environment for Ruby on Rails 6 (rvm, rbenv, .ruby-version issues)

我一直试图弄清楚如何在我的 macOS 上使用 cli 将一个简单的 rails 应用程序部署到弹性 beanstalk,但每次我进入eb create时都会收到此错误:

2020/08/06 07:22:56.626563 [INFO] Executing instruction: StageApplication
2020/08/06 07:22:56.626674 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2020/08/06 07:22:56.626695 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2020/08/06 07:22:56.638657 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2020/08/06 07:22:56.640331 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/06 07:22:56.640351 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2020/08/06 07:22:56.640356 [INFO] Executing instruction: stage ruby application
2020/08/06 07:22:56.640360 [INFO] stage ruby application ....
2020/08/06 07:22:56.640386 [INFO] Running command /bin/sh -c bundle config set --local deployment true
2020/08/06 07:22:56.669550 [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 `ruby-2.7.0' is not installed (set by /var/app/staging/.ruby-version)

然后我运行eb terminate ,这样我就不会被收取任何费用。 错误只是说我没有安装 2.7.0,即使我的 Gemfile 列出了 2.7.1 并且我运行bundle install没有任何问题。

对于 eb 平台版本,我选择了此处列出的第一个选项,即 Ruby 2.7.1-p83,这是我的ruby -v当前返回的内容,所以我不确定它为什么要寻找 2.7.0...

我使用 rvm 来更新到最新的 Ruby,之前我有 Ruby 2.6.3,底部的错误说'ruby-2.6.3' is not installed' 在我的 Mac 上使用 rbenv 更新到最新版本的 Ruby 很困难,我认为是因为我的系统版本 Ruby 有问题? 所以我从 brew 中删除了 rbenv 并开始使用 rvm 。 但我觉得这就是问题所在,因为看起来弹性豆茎正在使用 rbenv 来尝试找到 Ruby 的正确版本? Stderr:rbenv: version `ruby-2.7.0' is not installed

任何帮助或指导都将不胜感激,即使只是了解“.ruby-version”是什么,或者 rvm 是否不应该用于部署。

“.ruby-version”是保存在项目根目录下的文件,指示您正在使用的 ruby 版本,因此它会自动读取版本。 (如果那是你问的)

对于您的问题,您必须确保正确应用 ruby 版本。

  1. 检查安装在 EC2 实例中的 ruby 版本。

您可以通过 ssh eb ssh然后ruby -v检查结果将是您需要使用的 Z58E53D13024EEF6AAB8 版本 (最好直接在EC2实例上查看,如果通过EB查看可能会有所不同)

  1. 确保您的.gemfile.ruby-version文件声明了正确的版本。

如果您还没有.ruby-version文件,请使用您在步骤 1 中获得的版本创建一个。

我正在处理同样的问题,并且安装在 EC2 实例中的 ruby 版本与我制作eb health --refresh时返回的版本不同,所以我按照上述步骤操作,然后重建我的环境并且它工作了,所以你可能还需要重建您的环境

暂无
暂无

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

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