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

Add 'fiddle' gem as a runtime dependency #852

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidrunger
Copy link

@davidrunger davidrunger commented Sep 6, 2024

Fixes #851

The following warning is printed to stderr when using byebug on Ruby 3.3.5:

/home/david/.rbenv/versions/3.3.5/lib/ruby/3.3.0/reline.rb:9: warning: fiddle was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.

You can add fiddle to your Gemfile or gemspec to silence this warning.

This change aims to cause that warning no longer to appear, by implementing one of the suggestions in the warning message, i.e. by adding the fiddle gem to byebug's gemspec as a runtime dependency.

Fixes deivid-rodriguez#851

The following warning is printed to stderr when using byebug on Ruby
3.3.5:

> /home/david/.rbenv/versions/3.3.5/lib/ruby/3.3.0/reline.rb:9: warning:
> fiddle was loaded from the standard library, but will no longer be
> part of the default gems starting from Ruby 3.5.0.
>
> You can add fiddle to your Gemfile or gemspec to silence this warning.

This change aims to cause that warning no longer to appear, by
implementing one of the suggestions in the warning message, i.e. by
adding the `fiddle` gem to byebug's gemspec as a runtime dependency.
@davidrunger
Copy link
Author

davidrunger commented Sep 6, 2024

Here's the reproduction script from issue #851, but modified to use this branch, rather than the master branch of this repo:

# File: run-byebug-from-inline-gemfile.rb
# Run with: `ruby run-byebug-from-inline-gemfile.rb`

require 'bundler/inline'

gemfile do
  ruby '3.3.5'
  source 'https://rubygems.org'
  gem 'byebug', github: 'davidrunger/byebug', ref: '731e9dc15eee40bde99f46c12c68c32f09f0d806'
end

puts("Ruby version: #{RUBY_VERSION}")

require 'byebug/version'
puts("Byebug version: #{Byebug::VERSION}")

require 'fiddle/version'
puts("Fiddle version: #{Fiddle::VERSION}")

byebug

When executed, that modified version of the script does not print the warning about fiddle that is documented in the issue report; it just prints this:

$ ruby run-byebug-from-inline-gemfile.rb
Ruby version: 3.3.5
Byebug version: 11.1.3
Fiddle version: 1.1.2

@@ -25,5 +25,7 @@ Gem::Specification.new do |s|
s.extensions = ["ext/byebug/extconf.rb"]
s.require_path = "lib"

s.add_dependency "fiddle", "~> 1.0"
Copy link
Author

@davidrunger davidrunger Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely feels kind of sad to be taking byebug from being a dependency-free gem to now having a runtime dependency, but I guess that unfortunately that might sort of be the inevitable result of Ruby moving more and more of its non-core functionality out of the standard library and into gems.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure which version specifier to put here. I went with ~> 1.0 because:

  1. fiddle v1.0.0 was released quite a while ago, on 2017-12-06 (source).
  2. That ensures that we will require the latest fiddle major version (i.e. version 1) and that we won't pull in any subsequent major version (e.g. version 2) that might include breaking changes.

@davidrunger
Copy link
Author

Caveat ❗

This PR should probably only be merged if byebug actually needs (or at least benefits from) something that is provided by the fiddle gem.

(Unfortunately, I personally have no idea whether or not that is the case.)

If byebug does not need any of the functionality of fiddle, then it might be / probably is possible and maybe also worthwhile to figure out some other solution to #851 that does not entail adding fiddle as a not-actually-needed dependency.

@Earlopain
Copy link

This warning is comming from the reline gem, which itself has an optional dependency on fiddle. The warning will be gone in Ruby 3.3.6 because of ruby/ruby#11558. Also see ruby/reline#721. Ruby decided to backport warnings for a few gems (why?)

On the other hand, reline should be added as a runtime dependency because you will get a warning for that with Ruby 3.4 (byebug requires readline but it is just an alias): ruby/ruby#11560

@davidrunger
Copy link
Author

davidrunger commented Sep 6, 2024

@Earlopain Thank you for all of those helpful pointers/links!

This warning is comming from the reline gem, which itself has an optional dependency on fiddle.

FWIW, I think that this is not technically quite true. At least, in my reproduction script, I think that reline is sourced from the Ruby 3.3.5 standard library, rather than coming from the reline gem.

If I add this content to the script:

require 'reline/version'
puts("Reline version: #{Reline::VERSION}")
puts("Reline version source: #{Reline.const_source_location(:VERSION)}")

Then it prints this:

Reline version: 0.5.7
Reline version source: ["/home/david/.rbenv/versions/3.3.5/lib/ruby/3.3.0/reline/version.rb", 2]

which seems to reference a path in the Ruby 3.3.5 standard library.

If I add to the gemfile block of the reproduction script this line:

gem 'reline'

then this gets printed:

Reline version: 0.5.10
Reline version source: ["/home/david/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/version.rb", 2]

In that case, we can see that the path is from the gem version of reline (and also that the version is more up to date, because it comes from the latest version of the gem, rather than the outdated Ruby 3.3.5 standard library version).

Maybe this little detail doesn't matter much, but I mention it for clarity, and in case it does somehow matter.

The warning will be gone in Ruby 3.3.6 because of ruby/ruby#11558.

That's very helpful info. I guess maybe it's acceptable, if 3.3.5 is the only Ruby version that will see these warnings? Maybe just close this PR and take no action to try to suppress that warning on Ruby 3.3.5?

Maybe it's worth mentioning that a number of my projects that use byebug actually don't ultimately print this warning, because there is some other gem in the project's bundle that requires the reline gem, even though byebug itself doesn't request the reline gem as a dependency. In that case, I think that having reline in the Gemfile dependency tree at all causes all require "reline" statements to pull from the reline gem (rather than from the standard library), which avoids this warning (due to ruby/reline#721, as you kindly linked to), even when the require is ultimately triggered from byebug, which doesn't explicitly have reline or fiddle as a dependency.

While pulling in the reline gem will suppress the warning about fiddle, it won't actually ensure that fiddle is made available, right? I still don't know whether or not there is any value in making sure that we actually do include fiddle (i.e. what this PR does), and it seems relevant, to help inform the best way forward. I think that I might have heard some mention somewhere that fiddle is necessary in order for things to work correctly on Windows?

@Earlopain
Copy link

FWIW, I think that this is not technically quite true. At least, in my reproduction script, I think that reline is sourced from the Ruby 3.3.5 standard library, rather than coming from the reline gem.

It is using the standard library version, yes. In ruby 3.3.5 some warnings were backported, but the standard library versions did not get appropriately updated, which means ruby's own standard library is now emitting these warnings. It is rather unfortunate, reline is not the only gem this happened to.

Even in the standard library I would still call it a gem, but the semantics don't really matter.

I guess maybe it's acceptable, if 3.3.5 is the only Ruby version that will see these warnings? Maybe just close this PR and take no action to try to suppress that warning on Ruby 3.3.5

I'd love for ruby to release 3.3.6 right now but I doubt this is going to happen. There was no release when 3.3.3 broke net-pop bundler resolution. Personally, I don't think libraries should work around ruby deficiencies like this, and it is just a warning. The next release will be in about ~2 months.

Maybe it's worth mentioning that a number of my projects that use byebug actually don't ultimately print this warning

Yes, if even just one direct/transient dependency pulls it in, the warnings will not show. I don't find it optimal but it is the way it is, and to be fair it has worked rather ok for now with previous warnings. You just need one person to alert the library author.

While pulling in the reline gem will suppress the warning about fiddle, it won't actually ensure that fiddle is made available, right?

That's correct, yes. I would think if any functionality actually relies on it, then reline would bump its major version instead of dropping that in a patch version. But that's just a guess, I'm as clueless as you in that regard.

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