Project

General

Profile

Actions

Bug #15621

closed

system({}, ...) breaks nonascii ENV["PATH"] on Windows

Added by kenhys (Kentaro Hayashi) over 2 years ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]
[ruby-core:91620]

Description

Problem

It seems that system({}, ...) breaks nonascii ENV["PATH"] after execution.
system(...) isn't affected. Only system(env, ...) is affected.

OS: Windows 7
Ruby: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.1-1/rubyinstaller-2.6.1-1-x64.exe
chcp: 現在のコード ページ: 932

Expected

system({}, ...) doesn't break nonascii ENV["PATH"] environment variable after execution.

Actual

Here is the sample code to reproduce this issue.

cat break-env-system.rb
# coding: cp932
ENV["PATH"] = [
  "インストール",
  ENV["PATH"],
].join(File::PATH_SEPARATOR)

env = {}
p ENV["PATH"]
system(env, "echo")
p ENV["PATH"]

It produces the following output:

"インストール;%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files\\CMake\\bin;C:\\GnuWin32\\bin;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\patch-2.5.9-7-bin\\bin;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Ruby26-x64\\bin"
ECHO は <ON> です。
"?C???X?g?[??;%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files\\CMake\\bin;C:\\GnuWin32\\bin;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\patch-2.5.9-7-bin\\bin;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Ruby26-x64\\bin"

If system("echo") is used instead of system({}, "echo"), ENV["PATH"] is not broken.


Files

break-env-system.rb (163 Bytes) break-env-system.rb reproducible sample code kenhys (Kentaro Hayashi), 02/25/2019 08:42 AM

Updated by jeremyevans0 (Jeremy Evans) about 1 month ago

  • Status changed from Open to Closed

Starting in Ruby 3.0, it appears ENV["PATH"] is unmodified after the call to system. In prior versions of Ruby, it was modified by the call to system. This is probably related to the changes to ENV in Ruby 3.0, which will not be backported to earlier Ruby versions.

Actions

Also available in: Atom PDF