Issue #12475 has been updated by Tomoyuki Chikanaga.

Backport changed from 2.1: DONTNEED, 2.2: WONTFIX, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: WONTFIX, 2.3: WONTFIX

----------------------------------------
Bug #12475: SHARABLE_MIDDLE_SUBSTRING=1のとき、環境変数が正しく設定されない
https://bugs.ruby-lang.org/issues/12475#change-59982

* Author: Kazuhiro NISHIYAMA
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.4.0dev (2016-06-09 trunk 55344) [x86_64-linux]
* Backport: 2.1: DONTNEED, 2.2: WONTFIX, 2.3: WONTFIX
----------------------------------------
`-DSHARABLE_MIDDLE_SUBSTRING=1` でビルドすると以下の failures がでます。

```
[15969/16628] TestTimeTZ#test_gen_right_America_Los_Angeles_91 = 0.00 s
  3) Failure:
TestTimeTZ#test_gen_right_America_Los_Angeles_91 [/home/vagrant/ruby/test/ruby/test_time_tz.rb:257]:
TZ=right/America/Los_Angeles Time.utc(1972, 6, 30, 23, 59, 60).
<"1972-06-30 23:59:60 UTC"> expected but was
<"1972-07-01 00:00:00 UTC">.

[15970/16628] TestTimeTZ#test_gen_right_America_Los_Angeles_92 = 0.00 s
  4) Failure:
TestTimeTZ#test_gen_right_America_Los_Angeles_92 [/home/vagrant/ruby/test/ruby/test_time_tz.rb:257]:
TZ=right/America/Los_Angeles Time.utc(2008, 12, 31, 23, 59, 60).
<"2008-12-31 23:59:60 UTC"> expected but was
<"2009-01-01 00:00:00 UTC">.

[15971/16628] TestTimeTZ#test_gen_right_America_Los_Angeles_95 = 0.00 s
  5) Failure:
TestTimeTZ#test_gen_right_America_Los_Angeles_95 [/home/vagrant/ruby/test/ruby/test_time_tz.rb:277]:
TZ=right/America/Los_Angeles Time.local(1972, 6, 30, 16, 59, 60).
<"1972-06-30 16:59:60 -0700"> expected but was
<"1972-06-30 17:00:00 +0000">.

[15972/16628] TestTimeTZ#test_gen_right_America_Los_Angeles_96 = 0.00 s
  6) Failure:
TestTimeTZ#test_gen_right_America_Los_Angeles_96 [/home/vagrant/ruby/test/ruby/test_time_tz.rb:277]:
TZ=right/America/Los_Angeles Time.local(2008, 12, 31, 15, 59, 60).
<"2008-12-31 15:59:60 -0800"> expected but was
<"2008-12-31 16:00:00 +0000">.
```

原因を調べてみたところ、`ENV.[]=` で環境変数が正しく設定されていませんでした。

```
$ irb -r irb/completion --simple-prompt
>> ENV["TZ"]="right/America/Los_Angeles.".chop
=> "right/America/Los_Angeles"
>> Time.utc(1972, 6, 30, 23, 59, 60)
=> 1972-07-01 00:00:00 UTC
>> ENV["TZ"]
=> "right/America/Los_Angeles."
>>
```




-- 
https://bugs.ruby-lang.org/