Skip to content

Bug in codedeplouy-agent script - does not select correct ruby #285

Closed
@drzee99

Description

@drzee99

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions