Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open3 does not look at ENV to find the path #1902

Closed
JoshCheek opened this issue Aug 14, 2014 · 1 comment
Closed

Open3 does not look at ENV to find the path #1902

JoshCheek opened this issue Aug 14, 2014 · 1 comment
Milestone

Comments

@JoshCheek
Copy link

A program:

require 'open3'

# ADD CWD TO PATH
cwd = File.expand_path '..', __FILE__
ENV['PATH'] = "#{cwd}:#{ENV['PATH']}"

# WRITE A BINARY THAT PRINTS OUT ZOMG
binary_name = File.join(cwd, "my-program")
File.write binary_name, "#!/bin/sh \n echo zomg"
File.chmod 0755, binary_name

# BACKTICKS FIND IT
puts "FROM SYSTEM:"
puts `my-program`

# OPEN3 FINDS IT IF I PASS ENV
puts "\nFROM OPEN3 WITH ENV:"
out, * = Open3.capture3(ENV, 'my-program')
puts out

# OPEN3 DOES NOT FIND IT IF I DO NOT PASS ENV
puts "\nFROM OPEN3 WITHOUT ENV:"
out, * = Open3.capture3('my-program')
puts out

Run under ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

FROM SYSTEM:
zomg

FROM OPEN3 WITH ENV:
zomg

FROM OPEN3 WITHOUT ENV:
zomg

Run under jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_51-b13 [darwin-x86_64]

FROM SYSTEM:
zomg

FROM OPEN3 WITH ENV:
zomg

FROM OPEN3 WITHOUT ENV:
IOError: Cannot run program "my-program" (in directory "/Users/josh/code/seeing_is_believing"): error=2, No such file or directory
    popen3 at org/jruby/RubyIO.java:4375
    popen3 at /Users/josh/.rubies/jruby-1.7.12/lib/ruby/1.9/open3.rb:74
  capture3 at /Users/josh/.rubies/jruby-1.7.12/lib/ruby/1.9/open3.rb:272
    (root) at f.rb:23
@kares
Copy link
Member

kares commented Jun 22, 2017

seems to be working on 9K (9.1.11.0), and JRuby 1.7.x is now EOL

@kares kares closed this as completed Jun 22, 2017
@kares kares added this to the Won't Fix milestone Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants