2010/9/14 Peter Weldon <redmine / ruby-lang.org>:
> Issue #3825 has been updated by Peter Weldon.
>
>
> Knowing the value of GetLastError() after SetEnvironmentVariable() fails may give a clue. Can you try get that?
>
> In VS, I would, add "$err,hr" to my watch window and put a break point at the fail: label in hash.c (setenv).

The value of GetLastError() is 203 and which defined as
#define ERROR_ENVVAR_NOT_FOUND      203

I am not sure in which case, SetEnvironmentVariable() with null value fails.

The another possible patch is

--- hash.c      2010-09-14 09:47:12.000000000 +0900
+++ hash.c.new  2010-09-14 09:47:12.000000000 +0900
@@ -2158,7 +2158,7 @@
     rb_str_resize(buf, 0);
     if (!value || !*value) {
        /* putenv() doesn't handle empty value */
-       if (!SetEnvironmentVariable(name,value)) goto fail;
+       if (!SetEnvironmentVariable(name,value) && GetLastError() !=
ERROR_ENVVAR_NOT_FOUND) goto fail;
     }
     if (failed) goto fail;
 #elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)