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

Remove base64 runtime dependency #932

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

mattbrictson
Copy link
Contributor

Starting in Ruby 3.3.0, require "base64" triggers a warning:

base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec.

Rather than introduce a new dependency, this commit removes the base64 requirement in favor of using String#pack and String#unpack1 directly. (The base64 gem is just a thin wrapper around these methods.)

I left base64 as a development dependency so that the existing tests could continue to use Base64, to confirm there are no regressions due to my changes.

The approach in this PR is similar to that used in several other gems, including:

Starting in Ruby 3.3.0, `require "base64"` triggers a warning:

> base64 was loaded from the standard library, but will no longer be
> part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile
> or gemspec.

Rather than introduce a new dependency, this commit removes the base64
requirement in favor of using `String#pack` and `String#unpack1`
directly. (The base64 gem is just a thin wrapper around these methods.)

I left base64 as a development dependency so that the existing tests
could continue to use `Base64`, to confirm there are no regressions due
to my changes.
@mfazekas
Copy link
Collaborator

@mattbrictson thanks much, this look good!

@mfazekas mfazekas merged commit add141b into net-ssh:master Jan 5, 2024
8 checks passed
@mfazekas
Copy link
Collaborator

mfazekas commented Jan 5, 2024

@mattbrictson mattbrictson deleted the fix-base64-warning branch January 5, 2024 15:15
@mattbrictson
Copy link
Contributor Author

@mfazekas testing against 7.2.2.rc1, and unfortunately I still see the warning:

net-ssh-7.2.2.rc1/lib/net/ssh/known_hosts.rb:3: warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of net-ssh-7.2.2.rc1 to add base64 into its gemspec.

It looks like this PR was incomplete: I forgot to remove the require "base64" statements. I'll open another PR.

mattbrictson added a commit to mattbrictson/net-ssh that referenced this pull request Jan 7, 2024
The previous PR net-ssh#932 refactored the code to no longer use the Base64
module, but forgot to remove the actual `require "base64"` statements.
This follow up commit removes those requires to fix the following
warning on Ruby 3.3:

> net/ssh/known_hosts.rb:3: warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of net-ssh-7.2.2.rc1 to add base64 into its gemspec.
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

Successfully merging this pull request may close these issues.

2 participants