{"action":"created","issue":{"url":"https://api.github.com/repos/jarib/childprocess/issues/89","labels_url":"https://api.github.com/repos/jarib/childprocess/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/jarib/childprocess/issues/89/comments","events_url":"https://api.github.com/repos/jarib/childprocess/issues/89/events","html_url":"https://github.com/jarib/childprocess/issues/89","id":96972588,"number":89,"title":"Strange \"Command not found\"-error.","user":{"login":"maxmeyer","id":114236,"avatar_url":"https://avatars.githubusercontent.com/u/114236?v=3","gravatar_id":"","url":"https://api.github.com/users/maxmeyer","html_url":"https://github.com/maxmeyer","followers_url":"https://api.github.com/users/maxmeyer/followers","following_url":"https://api.github.com/users/maxmeyer/following{/other_user}","gists_url":"https://api.github.com/users/maxmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/maxmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxmeyer/subscriptions","organizations_url":"https://api.github.com/users/maxmeyer/orgs","repos_url":"https://api.github.com/users/maxmeyer/repos","events_url":"https://api.github.com/users/maxmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/maxmeyer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-24T06:08:30Z","updated_at":"2015-08-12T12:36:21Z","closed_at":null,"body":"We see some of our tests failing with jruby:\r\n\r\n~~~\r\n     Failure/Error: before(:each) { run(cmd) }\r\n     Aruba::LaunchError:\r\n       Cannot run program \"cmd.sh\" (in directory \"/home/user/data/projects/aruba/tmp/aruba\"): error=2, No such file or directory\r\n~~~\r\n\r\nWe're using `ChildProcess` in [`aruba`](https://github.com/cucumber/aruba) to run shell commands with this peace of code:\r\n\r\n~~~ruby\r\n      def start\r\n        @process     = ChildProcess.build(command, *arguments)\r\n        @stdout_file = Tempfile.new(\"aruba-stdout\")\r\n        @stderr_file = Tempfile.new(\"aruba-stderr\")\r\n        @exit_status = nil\r\n        @duplex      = true\r\n\r\n        before_run\r\n\r\n        @process.io.stdout = @stdout_file\r\n        @process.io.stderr = @stderr_file\r\n        @process.duplex    = @duplex\r\n        @process.cwd       = @working_directory\r\n\r\n        @process.environment.update(environment)\r\n\r\n        begin\r\n          with_local_env(environment) do\r\n            @process.start\r\n          end\r\n        rescue ChildProcess::LaunchError => e\r\n          raise LaunchError, e.message\r\n        end\r\n~~~\r\n\r\nThe `#with_environment`-methods has the following code:\r\n\r\n~~~ruby\r\ndef with_environment(env = {}, &block)\r\n  if RUBY_VERSION <= '1.9.3'\r\n    old_env = ENV.to_hash.dup\r\n  else\r\n    old_env = ENV.to_h.dup\r\n  end\r\n\r\n  old_aruba_env = aruba.environment.to_h\r\n\r\n  ENV.update aruba.environment.update(env).to_h\r\n\r\n  block.call if block_given?\r\nensure\r\n  ENV.clear\r\n  ENV.update old_env\r\nend\r\n~~~\r\n\r\nIf we run our build on Travis with `mri`-rubies everything is fine, but with `jruby` (1.7.x, 9000) it fails:\r\nhttps://travis-ci.org/cucumber/aruba/jobs/72323854#L1088\r\n\r\nLooking at your sources, [line 77](/home/d/.gem/jruby/gems/childprocess-0.5.6/lib/childprocess/jruby/process.rb:77) seems to cause the trouble. Running `pb.start` before `pb.environment` is invoked works. After `pb.environment` was called it failes. I see no difference within ENV and `Dir.getwd`:\r\n\r\n~~~\r\n[1] pry(#<ChildProcess::JRuby::Process>)> Dir.getwd\r\n=> \"/home/user/data/projects/aruba\"\r\n[2] pry(#<ChildProcess::JRuby::Process>)> ENV['PATH']\r\n=> \"/home/user/data/projects/aruba/tmp/aruba:/home/user/data/projects/aruba/bin:/home/user/.gem/jruby/bin:/home/user/.gem/2.2.2/bin:/home/user/.local/share/npm/bin:/home/user/.local/share/golang/bin:/home/user/.local/share/go/bin:/home/user/bin:/home/user/.gem/ruby/2.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/user/.rvm/bin\"\r\n~~~\r\n\r\nBut it seems to me, that some Java-code is involved. Unfortunately I've no experience how to debug jruby java code. Maybe you can have a look into it?\r\n\r\n1. Clone `aruba` repository, https://github.com/cucumber/aruba\r\n2. `bundle install`\r\n3.  `jruby /home/user/.gem/jruby/bin/rspec ./spec/aruba/matchers/command_spec.rb:128`\r\n\r\nBTW:\r\nThis is how I run the rspec command on my local machine. Where it fails as well:\r\n\r\n~~~bash\r\nJRUBY_OPTS='--dev' GEM_HOME=~/.gem/jruby GEM_PATH=~/.gem/jruby GEM_ROOT=~/.gem/jruby jruby /home/user/.gem/jruby/bin/rspec ./spec/aruba/matchers/command_spec.rb:128\r\n~~~\r\n\r\nThanks a lot.\r\n\r\n@mattwynne Ping."},"comment":{"url":"https://api.github.com/repos/jarib/childprocess/issues/comments/130285908","html_url":"https://github.com/jarib/childprocess/issues/89#issuecomment-130285908","issue_url":"https://api.github.com/repos/jarib/childprocess/issues/89","id":130285908,"user":{"login":"dg-ratiodata","id":1267524,"avatar_url":"https://avatars.githubusercontent.com/u/1267524?v=3","gravatar_id":"","url":"https://api.github.com/users/dg-ratiodata","html_url":"https://github.com/dg-ratiodata","followers_url":"https://api.github.com/users/dg-ratiodata/followers","following_url":"https://api.github.com/users/dg-ratiodata/following{/other_user}","gists_url":"https://api.github.com/users/dg-ratiodata/gists{/gist_id}","starred_url":"https://api.github.com/users/dg-ratiodata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dg-ratiodata/subscriptions","organizations_url":"https://api.github.com/users/dg-ratiodata/orgs","repos_url":"https://api.github.com/users/dg-ratiodata/repos","events_url":"https://api.github.com/users/dg-ratiodata/events{/privacy}","received_events_url":"https://api.github.com/users/dg-ratiodata/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T12:36:21Z","updated_at":"2015-08-12T12:36:21Z","body":"The problem occures with jruby 9000 as well: jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 OpenJDK 64-Bit Server VM 24.85-b03 on 1.7.0_85-b01 +jit [linux-amd64]\r\n"}}