By using AWS re:Post, you agree to the Terms of Use

Ruby version mismatch while deploying Rails App with CodeDeploy and CodePipeline Scripts on Ubuntu 20.0 EC2


So my Rails Application is running on Ruby2.5.7 and Rails 5.1.5. I have added appspec.yml which include multiple scripts to setup my app like

  1. Setting up ENV variables
  2. Installing Gems
  3. Migrations
  4. Assets Compile etc.

I have also installed rbenv and installed ruby 2.5.7 on instance but every time i trigger deploy the code deploy agent is using ruby 2.7 and trying to install gems on that version which is raising error Your Ruby version is 2.7.0, but your Gemfile specified 2.5.7. My Gemfile specifies 2.5.7 and .ruby-version is also present. I tried to switch the ruby version in myscript but nothing is working.