Project

General

Profile

Actions

Feature #22329

open

Specify --disable-gem per Ruby Box

Feature #22329: Specify --disable-gem per Ruby Box

Added by tagomoris (Satoshi Tagomori) 3 days ago. Updated 3 days ago.

Status:
Open
Target version:
[ruby-core:126758]
Tags:

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_suggest similar to the command line options
  • have only disable_gems to 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.

Actions

Also available in: PDF Atom