Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mattbrictson opened this issue Jan 12, 2025 · 2 comments
Open

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

mattbrictson opened this issue Jan 12, 2025 · 2 comments

Comments

@mattbrictson
Copy link
Member

mattbrictson commented Jan 12, 2025

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.

@mattbrictson
Copy link
Member Author

A third potential option is to write our own base64 implementation to eliminate the gem dependency.

However, this will give us only a short reprieve, since logger is being removed as a built-in gem in future versions of Ruby, and we will have the same problem there as well. The logger gem also does not support Ruby <= 2.2.

@mattbrictson mattbrictson changed the title Can't install sshkit on Ruby 2.2 or older Can't install latest sshkit on Ruby 2.2 or older Jan 12, 2025
@will-in-wi
Copy link
Contributor

I'd lean towards not supporting older Ruby. According to https://www.ruby-lang.org/en/downloads/branches/, Ruby 2.1 went out of support on 2017-03-31. That's a long time ago in computer terms. And if someone is forced to use a very old version of Ruby, they do have the option of pinning Capistrano to an older version too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants