Feature #22329
openSpecify --disable-gem per Ruby Box
Description
Currently user boxes loads gems listed in the gem_prelude.rb if those gems are enabled in the process-wide.
There is just only way to disable gems in boxes: specify --disable-gems in the entire process.
This proposes a new keyword argument on Ruby::Box#new to disable gems per box.
This makes possible to create a simple, clean boxes if the box doesn't require RubyGems and other bundled gems. Boxes without RubyGems are still useful for loading small scripts, reducing security risks by keeping load_path clean&simple, etc.
# RubyGems is enabled in main
Gem #=> Gem
# Create a box without RubyGems
box = Ruby::Box.new(disable_gems: true)
box::Gem # NameError
The default value of disable_gems is `false.
There may be two options to have keyword arguments:
- have all of
disable_gems,error_highlight,did_you_mean,syntax_suggestsimilar to the command line options - have only
disable_gemsto disable all of 4 gems
IMO having only disable_gems looks enough because all of RubyGems/ErrorHightlight/DidYouMean/SyntaxSuggest bring the better developer experience. The single keyword argument disable_gems can explain well: "this box doesn't expect those developer-centric features".
Another discussion point is how we should handle Ruby::Box.new(disable_gems: false) when the process-wide --disable-gems is specified.
Options:
- respect the process-wide selection and leave RubyGems an others are not loaded
- try to load RubyGems and others only in the box
I prefer the first option, but it's not a strong opinion.