Project

General

Profile

Actions

Bug #3825

closed

ENV.delete raise Exception on Windows

Added by phasis68 (Heesob Park) almost 12 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.3dev (2010-09-12 trunk 29234) [i386-mswin32_90]
Backport:
[ruby-core:32353]

Description

=begin
ENV.delete raises Invalid argument Exception on Windows.

The error is due to trying SetEnvironmentVariable even if putenv succeeded.

C:>ruby -ve "ENV['foo']='bar';ENV.delete('foo')"
ruby 1.9.3dev (2010-09-12 trunk 29234) [i386-mswin32_90]
-e:1:in delete': Invalid argument - ruby_setenv (Errno::EINVAL) from -e:1:in '

The patch is simple as like this:

--- hash.c.org 2010-09-13 11:31:01.000000000 +0900
+++ hash.c 2010-09-13 11:51:08.000000000 +0900
@@ -2156,7 +2156,7 @@
/* even if putenv() failed, clean up and try to delete the
* variable from the system area. */
rb_str_resize(buf, 0);

  • if (!value || !*value) {
  • if (failed && (!value || !value)) {
    /
    putenv() doesn't handle empty value */
    if (!SetEnvironmentVariable(name,value)) goto fail;
    }
    =end
Actions

Also available in: Atom PDF