Issue #8004 has been updated by Nobuyoshi Nakada.

Description updated

----------------------------------------
Bug #8004: spawn does not honor its passed PATH
https://bugs.ruby-lang.org/issues/8004#change-61352

* Author: Josh Cheek
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
```
#!/bin/sh

# make an executable
  echo '#!/usr/bin/env ruby' >  my_bin
  echo 'puts "omg"'          >> my_bin
  chmod +x my_bin


# run it in 1.9
  ruby1.9 -v
    # >> ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]

  ruby1.9 -r open3 -e 'p Open3.capture3({"PATH" => ".:#{ENV["PATH"]}"}, "my_bin")'
    # >> ["omg\n", "", #<Process::Status: pid 30556 exit 0>]

# run it in 2.0
  ruby2 -v
    # >> ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]

  ruby2 -r open3 -e 'p Open3.capture3({"PATH" => ".:#{ENV["PATH"]}"}, "my_bin")'
    # >> /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/open3.rb:211:in `spawn': No such file or directory - my_bin (Errno::ENOENT)
    # >>   from /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/open3.rb:211:in `popen_run'
    # >>   from /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/open3.rb:99:in `popen3'
    # >>   from /Users/joshcheek/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/open3.rb:279:in `capture3'
    # >>   from -e:1:in `<main>'

  # the above fails, but this one works
  ruby2 -r open3 -e 'ENV["PATH"] = ".:#{ENV["PATH"]}"; p Open3.capture3("my_bin")'
    # >> ["omg\n", "", #<Process::Status: pid 30556 exit 0>]

  # it is setting the path, though, so idk what the problem is
  ruby2 -r open3 -e 'p Open3.capture3({"PATH" => ".:#{ENV["PATH"]}"}, "echo $PATH")'
    # >> [".:/Users/joshcheek/.rbenv/shims: ...




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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>