-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Keep Rails::ConsoleMethods's module inclusion to IRB but raise deprecation warning #51760
Keep Rails::ConsoleMethods's module inclusion to IRB but raise deprecation warning #51760
Conversation
Due to some users/libs relying on Rails::ConsoleMethod to extend Rails console, we need to keep including it to IRB's internal. But to prevent also adding `app` and `helper` methods to the console, which are already registered to IRB through its API, we need to remove them from the Rails::ConsoleMethods. Additionally, we should raise deprecation warning when users try to use Rails::ConsoleMethods in this way. This commit: - Removes all methods from Rails::ConsoleMethods that are already registered to IRB. So it's now essentially empty. - Raises a deprecation warning when modules are included to Rails::ConsoleMethods or methods are added to it. - Adds a test to ensure that the deprecation warning is raised and the methods are available in the console.
201b3ac
to
484c026
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine it's not the only gem that's requiring this file :/
@st0012 thanks for the updates here! appreciate it. While I think that expecting libraries / frameworks like Rails to extend the console via the new IRB API is fine/great, I'm afraid this might be too much to ask for app devs. We might need to look into a simpler way to add methods to the console that doesn't require the extra plumbing of creating a class, adding a description, registering the command, etc... not sure. @ghiculescu maybe we bring back those files and make them just require the new one? They could be removed with the deprecated stuff later. |
Users can already create IRB commands without specifying meta attributes with @ghiculescu can you investigate what's causing the failure? My understanding is that the original |
It’s not my gem (I just use it) but I’ll have a look. I tend to agree with @carlosantoniodasilva though. It looks like things that are public API are just being deleted. |
@st0012 - https://github.com/basecamp/console1984/blob/215874e74daac9865ff09bf128be13b81b230c4f/lib/console1984/shield.rb#L37 This leads me to https://github.com/basecamp/console1984/blob/master/lib/console1984/ext/irb/commands.rb Through looking into this I also found rails/mission_control-jobs#117. Would we need to do a similar PR here? |
What I found after testing
|
I'm 100% ok with adding |
I've opened basecamp/console1984#112 to address the missing
That would solve my problem in the short term so I am 😍 on this. Over the long term that gem would need to get updated to the new IRB API I guess. |
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
@ghiculescu @carlosantoniodasilva I added the files back in #51839 |
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
This replaced "rails/console/app". See rails/rails#51760
This replaced "rails/console/app". See rails/rails#51760
This replaced "rails/console/app". See rails/rails#51760
This replaced "rails/console/app". See rails/rails#51760
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
It helps to find the code/gem that uses deprecated API. Enhances rails#51760 Previously when running rails console: ``` DEPRECATION WARNING: Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0. Please directly use IRB's extension API to add new commands or helpers to the console. For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md (called from include at /home/wojtek/.asdf/installs/ruby/3.3.2/lib/ruby/gems/3.3.0/gems/railties-7.2.0.beta2/lib/rails/console/methods.rb:6) Loading development environment (Rails 7.2.0.beta2) ``` After: ``` DEPRECATION WARNING: Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0. Please directly use IRB's extension API to add new commands or helpers to the console. For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md Called via `MissionControl::Jobs::Console::Helpers` (called from include at /home/wojtek/.asdf/installs/ruby/3.3.2/lib/ruby/gems/3.3.0/gems/railties-7.2.0.beta2/lib/rails/console/methods.rb:6) Loading development environment (Rails 7.2.0.beta2) ```
It helps to find the code/gem that uses deprecated API. Enhances rails#51760 Previously when running rails console: ``` DEPRECATION WARNING: Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0. Please directly use IRB's extension API to add new commands or helpers to the console. For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md (called from include at /home/wojtek/.asdf/installs/ruby/3.3.2/lib/ruby/gems/3.3.0/gems/railties-7.2.0.beta2/lib/rails/console/methods.rb:6) Loading development environment (Rails 7.2.0.beta2) ``` After: ``` DEPRECATION WARNING: Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0. Please directly use IRB's extension API to add new commands or helpers to the console. For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md Called via `MissionControl::Jobs::Console::Helpers` (called from include at /home/wojtek/.asdf/installs/ruby/3.3.2/lib/ruby/gems/3.3.0/gems/railties-7.2.0.beta2/lib/rails/console/methods.rb:6) Loading development environment (Rails 7.2.0.beta2) ```
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
Those files were removed in rails#51760, but gems like `console1984` depend on these files for legacy Rails console command extensions. So keeping files around is required for backward-compatibility.
Motivation / Background
@carlosantoniodasilva suggested in this tweet that the
Rails::ConsoleMethods
extension approach should still be supported.Detail
Due to some users/libs relying on Rails::ConsoleMethod to extend Rails console, we need to keep including it to IRB's internal.
But to prevent also adding
app
andhelper
methods to the console, which are already registered to IRB through its API, we need to remove them from the Rails::ConsoleMethods. Additionally, we should raise deprecation warning when users try to use Rails::ConsoleMethods in this way.This commit:
Additional information
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]