无法为Ruby on Rails 6创建弹性beantalk环境(rvm,rbenv,.ruby版本问题) [英] Trouble creating elastic beanstalk environment for Ruby on Rails 6 (rvm, rbenv, .ruby-version issues)

查看:45
本文介绍了无法为Ruby on Rails 6创建弹性beantalk环境(rvm,rbenv,.ruby版本问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找出如何使用macOS上的cli将简单的Rails应用程序部署到弹性beantalk,但是每次我进入 eb create 时,都会出现此错误:

I've been trying to figure out how to deploy a simple rails app to elastic beanstalk using the cli on my macOS, but every time I get to eb create I get this error:

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终止,这样我就不会为任何事情付费.该错误仅表示我没有安装2.7.0,即使我的Gemfile列出了2.7.1,并且我运行了 bundle install 也没有任何问题.

And then I run eb terminate so that I don't get charged for anything. The error just says I don't have 2.7.0 installed even though my Gemfile lists 2.7.1 and I ran bundle install without any issues.

对于eb平台版本,我选择了第一个选项

For the eb platform version I selected the first option listed here, so that would be Ruby 2.7.1-p83, which is what my ruby -v currently returns so I'm not sure why it's looking for 2.7.0...

我使用rvm来更新到最新的Ruby,以前我有Ruby 2.6.3,底部的错误是说'ruby-2.6.3'is not installed'.我认为很难在我的Mac上使用rbenv更新到最新版本的Ruby,因为它在我的系统版本的Ruby中存在问题?所以我从brew中删除了rbenv,开始使用rvm代替.但是我觉得这是问题所在,因为看起来像是弹性beanstalk正在使用rbenv尝试找到正确版本的Ruby? Stderr:rbenv:未安装版本"ruby​​-2.7.0"

I used rvm in order to update to the latest Ruby, previously I had Ruby 2.6.3 and the error at the bottom said 'ruby-2.6.3' is not installed'. It was difficult to use rbenv to update to the latest version of Ruby on my mac, I think because it had issues with my systems version of Ruby? So I removed rbenv from brew and started using rvm instead. But I feel this is where the problem lies, since it looks like elastic beanstalk is using rbenv to try and find the correct version of Ruby? Stderr:rbenv: version `ruby-2.7.0' is not installed

任何帮助或指导将不胜感激,甚至只是理解什么是".ruby-version".是,或者不应该使用rvm进行部署.

Any help or direction would be appreciated, even just an understanding of what ".ruby-version" is or if rvm shouldn't be used for deployment.

推荐答案

.ruby-version"是保存在项目根目录中的文件,用于指示您正在使用的红宝石版本,因此它将自动读取该版本.(如果这是您的要求)

".ruby-version" is a file saved at the root of your project that indicates what ruby version you are using, so it reads the version automatically. (if that's what you asked)

对于您的问题,您需要做一些事情以确保正确应用ruby版本.

For your problem, there are a couple of things you've got to make sure to ensure that the ruby version is applied correctly.

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

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

You can check this via ssh eb ssh and then ruby -v The result would be the ruby version that you need to use. (prefer to check it directly on the EC2 instance, it may differ if you check it through EB )

  1. 确保您的 .gemfile .ruby-version 文件具有声明的正确版本.
  1. Make sure your .gemfile and your .ruby-version files have the correct version declared.

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

If you do not have a .ruby-version file yet, Create one with the version you got in step 1.

我正在处理同一问题,并且EC2实例中安装的红宝石版本与我进行 eb health --refresh 时返回的版本不同,因此我按照上述步骤操作,并然后重建我的环境并且它起作用了,所以您可能还需要重建您的环境

I was dealing with the same issue, and the ruby version installed in the EC2 instance was different from what the one returned if I made eb health --refresh, so I followed the steps above and then rebuild my environment and it worked, so you may also need to rebuild your environment

这篇关于无法为Ruby on Rails 6创建弹性beantalk环境(rvm,rbenv,.ruby版本问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆