End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
ENV.clone
ENV.clone(freeze: nil) → ENV
hash.c
View on GitHub ↗
static VALUE
env_clone(int argc, VALUE *argv, VALUE obj)
{
if (argc) {
VALUE opt, kwfreeze;
if (rb_scan_args(argc, argv, "0:", &opt) < argc) {
kwfreeze = rb_get_freeze_opt(1, &opt);
if (RTEST(kwfreeze)) {
rb_raise(rb_eTypeError, "cannot freeze ENV");
}
}
}
rb_warn_deprecated("ENV.clone", "ENV.to_h");
return envtbl;
}
Returns ENV itself, and warns because ENV is a wrapper for the process-wide environment variables and a clone is useless. If freeze keyword is given and not nil or false, raises ArgumentError. If freeze keyword is given and true, raises TypeError, as ENV storage cannot be frozen.