Skip to content

Can't install latest sshkit on Ruby 2.2 or older #548

@mattbrictson

Description

@mattbrictson

Using Ruby 2.2:

# ruby -v 
ruby 2.2.10p489 (2018-03-28 revision 63023) [aarch64-linux]

Attempt to install sshkit:

# gem install sshkit
...
ERROR:  Error installing sshkit:
	There are no versions of base64 (>= 0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
	base64 requires Ruby version >= 2.4. The current ruby version is 2.2.0.

The problem is that we have added a dependency on the base64 gem in order to support Ruby 3.4+, but the base64 gem is not available on Ruby 2.2 or older.

In our gemspec, we have this line:

gem.add_runtime_dependency('base64') if RUBY_VERSION >= "2.4"

However, this doesn't work as intended. The RUBY_VERSION check is evaluated at gem publishing time, not at runtime. Assuming we publish the gem using a recent version of Ruby (which we do), then the gem will always have the base64 dependency, regardless of the Ruby version being used to install sshkit.

Further explanation about why it is bad to use RUBY_VERSION conditionals: rubocop/ruby-style-guide#763

Therefore, I think there are two potential fixes:

  1. Remove the base64 dependency entirely. This will fix installation on old versions of Ruby. However people using Ruby 3.4+ will have a bad experience: they will need to manually install base64 or add it to their Gemfile, otherwise sshkit won't work.
  2. Update sshkit to officially drop support for Ruby 2.2 and older.

I'm leaning toward dropping support for old versions of Ruby, given the fact that we have not received any bug reports from people using old versions of Ruby regarding this issue.

Edit: the last version of sshkit that seems to successfully install on Ruby 2.2 is sshkit 1.22.0.

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