Description
Have ruby2.7 and ruby3.0 installed with /usr/bin/ruby pointing to ruby3.0.
When starting the agent it does select ruby3.0 as the interpreter which does not work.
Looking at bin/codedeploy-agent there is code that is intended to look for a ruby2.Y binary as the interpreter. But its not working correctly as the "if" clause always will (if ruby3.0 is "actual_ruby_version") return TRUE and not branch into the "else" block (it will work correctly though if the default ruby binary is ruby1.x version)
To take both situations into account where /usr/bin/ruby points to ruby1.x or ruby3.x believe the "if" clause should be:
if (actual_ruby_version[0] <=> left_bound[0]) == 0
If ruby1.x or ruby3.x is the default ruby version it will force execution of the "else" clause and start looking for a ruby2.x binary in /usr/bin/
Some distributions may also use ruby-X.Y instead of rubyX.Y this is not taken into account in the startup script it only expects rubyX.Y as naming. To cover those suggest the following additional changes:
ruby_dir = "/usr/bin/ruby*#{i}"
if Dir[ruby_dir].any?