From: Heesob Park Date: 2010-09-13T12:05:11+09:00 Subject: [ruby-core:32353] [Ruby 1.9-Bug#3825][Open] ENV.delete raise Exception on Windows Bug #3825: ENV.delete raise Exception on Windows http://redmine.ruby-lang.org/issues/show/3825 Author: Heesob Park Status: Open, Priority: Normal Category: core, Target version: 1.9.x ruby -v: ruby 1.9.3dev (2010-09-12 trunk 29234) [i386-mswin32_90] 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; } ---------------------------------------- http://redmine.ruby-lang.org