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

Formatters cannot be set/got when your implementation does not support Ractors #191

Open
enebo opened this issue Dec 5, 2023 · 2 comments

Comments

@enebo
Copy link

enebo commented Dec 5, 2023

I was not passing some MRI pattern matching specs and realized that it was not setting the NullFormatter. It is because formatter requires Ractors to work.

I did a quick fix:

  # Returns the currently set formatter. By default, it is set to +DidYouMean::Formatter+.
  def self.formatter
    storage = defined?(Ractor) ? Ractor : Thread
    storage.current[:__did_you_mean_formatter__] || Formatter
  end

  # Updates the primary formatter used to format the suggestions.
  def self.formatter=(formatter)
    storage = defined?(Ractor) ? Ractor : Thread
    storage.current[:__did_you_mean_formatter__] = formatter
  end

but I suspect this is not right. This is a global setting and not just a thread-specific one...or is it?

@yuki24
Copy link
Member

yuki24 commented Mar 19, 2024

Apologies for the delay. Did you run into this issue on JRuby or older versions of MRI?

@enebo
Copy link
Author

enebo commented Mar 19, 2024

@yuki24 on JRuby. When we try and run C Ruby test suite it disables the did_you_mean formatter. JRuby has no Ractors so it doesn't replace the formatter.

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

No branches or pull requests

2 participants