'AWS Code Deploy Agent Needs ruby 2.x to run and you cant install older version of ruby (Work Around)

AWS Code Deploy Agent Needs ruby 2.x to run and you cant install older version of ruby with sudo apt install ruby

This is a work around.



Solution 1:[1]

installing older version of ruby 2.7.1 for code deploy
(1)

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

(2)

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

(3)

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

(4)

rbenv install 2.7.1
rbenv global 2.7.1

(5)

If ERROR: No acceptable C compiler found use
apt-get install build-essential

If your installation fails again, make sure you install the " libreadline-dev " and " zlib1g-dev " dependencies:
sudo apt-get -y install libssl-dev zlib1g-dev libreadline-dev

Try step (4) again

(6)

check for version
ruby -v

(7)

gem install bundler

(8)

rbenv rehash

(9)

Finally which ruby get the path of your ruby, copy the path

open codeploy agent install file the one you install with wget in your root dir
cd ~
and run sudo nano install

change the first line #!/usr/bin/env ruby to the path you copy #!/home/ubuntu/.rbenv/shims/ruby

and save the file and then install codedeploy agent again sudo ./install auto > /tmp/logfile

run sudo service codedeploy-agent status to see if it works, Hope it does. HAPPY CODING !!!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 emmanuel kofi