首页 > 解决方案 > 在部署到 EB 时升级 Ruby 版本

问题描述

我在 Ruby 上有一个生产 rails 应用程序,2.2.5但我将我的应用程序更新为 ruby2.5.3​​ 和 rails from 4.2to 5.2。当我尝试将其部署到 ElasticBeanstalk 时,每次都会收到以下错误:

Warning: the running version of Bundler is older than the version that created the lockfile. 
We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Your Ruby version is 2.2.5, but your Gemfile specified 2.5.3. 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

为了解决这个问题,我使用 ssh 进入实例并rvm在更新 ruby​​ 版本之前安装

rvm --default use 2.5.3

在此之后,我按照错误消息中的建议更新了我bundler的,但似乎 ruby​​ 版本会在2.2.5我每次关闭连接ssh时重新设置,因为这样做

ruby -v2.2.5

如何更新实例上的 ruby​​ 版本?

标签: ruby-on-railsrubyamazon-web-servicesamazon-ec2amazon-elastic-beanstalk

解决方案


Elastic Beanstalk 在平台中设置 Ruby 版本(您可以将其视为基础 AMI)。要升级它,您需要更新您的平台版本

根据您使用的网络服务器,听起来您需要以下之一:

  • 运行 Ruby 2.5 (Puma) 的 64 位 Amazon Linux 2018.03 v2.8.7
  • 运行 Ruby 2.5(乘客独立)的 64 位 Amazon Linux 2018.03 v2.8.7

推荐阅读