Comments (6)
That looks very odd. Do you have trouble running other programs in PATH as well, e.g. /bin/ls
? Does it work if you pass an absolute path to ChildProcess.build
?
from childprocess.
Yep, works fine for system programs like ls
and also works fine when passing an absolute path.
jruby-1.7.4 :001 > p = ChildProcess.build('ls')
=> #<ChildProcess::JRuby::Process:0x1244c1b9 @cwd=nil, @duplex=false, @detach=false, @exit_code=nil, @io=nil, @started=false, @args=["ls"], @environment={}, @pumps=[]>
jruby-1.7.4 :002 > p.start
=> #<ChildProcess::JRuby::Process:0x1244c1b9 @cwd=nil, @duplex=false, @process=#<Java::JavaLang::UNIXProcess:0x2bb47065>, @detach=false, @exit_code=nil, @io=nil, @started=true, @args=["ls"], @environment={}, @pumps=[]>
jruby-1.7.4 :001 > p = ChildProcess.build('/Users/joecorcoran/Projects/pannier/bin/pannier')
=> #<ChildProcess::JRuby::Process:0x694d3787 @duplex=false, @cwd=nil, @detach=false, @exit_code=nil, @io=nil, @started=false, @args=["/Users/joecorcoran/Projects/pannier/bin/pannier"], @environment={}, @pumps=[]>
jruby-1.7.4 :002 > p.start
=> #<ChildProcess::JRuby::Process:0x694d3787 @cwd=nil, @duplex=false, @process=#<Java::JavaLang::UNIXProcess:0x6e75eb9a>, @detach=false, @exit_code=nil, @io=nil, @started=true, @args=["/Users/joecorcoran/Projects/pannier/bin/pannier"], @environment={}, @pumps=[]>
from childprocess.
I tried to reproduce the problem with this script, and it seems to work well for me. Notice that
(a) I'm using rbenv, not rvm
(b) instead of replacing PATH
with ./bin
, I prepend it to the current PATH. Unless I do that, I get env: ruby: No such file or directory
- referring to the shebang line of ./bin/pannier
. That happens on both JRuby and MRI.
#/bin/bash
set -e
set -x
cd /tmp
rm -rf pannier
git clone https://github.com/joecorcoran/pannier.git
cd pannier
rbenv local jruby-1.7.4
ruby -v
bundle install
cat <<RUBY > test.rb
require 'childprocess'
process = ChildProcess.build("pannier")
process.io.inherit!
process.environment['PATH'] = File.join(Dir.pwd, 'bin') + ":" + ENV['PATH']
process.start
process.wait
RUBY
ruby test.rb
from childprocess.
Huh. I followed the steps from your above script exactly and it still fails.
$ irb -r childprocess
jruby-1.7.4 :001 > p = ChildProcess.build('pannier')
=> #<ChildProcess::JRuby::Process:0x4b564e68 @duplex=false, @cwd=nil, @detach=false, @exit_code=nil, @io=nil, @started=false, @args=["pannier"], @environment={}, @pumps=[]>
jruby-1.7.4 :002 > p.io.inherit!
=> #<IO:fd 2>
jruby-1.7.4 :003 > p.environment['PATH'] = File.join(Dir.pwd, 'bin') + ':' + ENV['PATH']
=> "/Users/joecorcoran/Projects/pannier/bin:/Users/joecorcoran/.rvm/gems/jruby-1.7.4/bin:/Users/joecorcoran/.rvm/gems/jruby-1.7.4@global/bin:/Users/joecorcoran/.rvm/rubies/jruby-1.7.4/bin:/Users/joecorcoran/.rvm/bin:/Users/joecorcoran/bin:/Users/joecorcoran/Repos/clojurescript/bin/cljsc:/usr/local/heroku/bin:/Users/joecorcoran/.nvm/v0.7.5/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/var/lib/gems/1.8/bin:/opt/local/bin:/opt/local/sbin:/opt/local/lib/mysql5/bin:/usr/local/mysql/bin"
jruby-1.7.4 :004 > p.start
ChildProcess::LaunchError: Cannot run program "pannier" (in directory "/Users/joecorcoran/Projects/pannier"): error=2, No such file or directory
from /Users/joecorcoran/.rvm/gems/jruby-1.7.4/gems/childprocess-0.3.9/lib/childprocess/jruby/process.rb:74:in `launch_process'
from /Users/joecorcoran/.rvm/gems/jruby-1.7.4/gems/childprocess-0.3.9/lib/childprocess/abstract_process.rb:72:in `start'
from (irb):4:in `evaluate'
from org/jruby/RubyKernel.java:1093:in `eval'
from org/jruby/RubyKernel.java:1489:in `loop'
from org/jruby/RubyKernel.java:1254:in `catch'
from org/jruby/RubyKernel.java:1254:in `catch'
from /Users/joecorcoran/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'
I wonder if we have different Java or JRuby patch versions?
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_40-b43 +indy [darwin-x86_64]
from childprocess.
So... I seem to have fixed this issue by simply adding my executable to the gemspec. I don't understand how you were able to get it to work beforehand. I guess since you're using rbenv, it might have been something to do with the combination of RVM and JRuby. After a frustrating couple of days I'm not inclined to keep looking. :)
Thanks very much for helping me to investigate anyway, and thanks for writing childprocess too.
from childprocess.
Thanks, glad you got it working.
from childprocess.
Related Issues (20)
- Redirect to IO.pipe on Windows causes inability to start a process HOT 6
- Security Question: Is there a reason childprocess is released as an unsigned gem? HOT 2
- FFI is a required pre-requisite HOT 4
- Pipe i/o example in documentation is incorrect HOT 2
- Erro ao rodar o comando rspec -fd HOT 1
- childprocess kills detached windows process on exit HOT 4
- FFI is a required pre-requisite for Windows or posix_spawn support in the ChildProcess gem. HOT 1
- A backend based on Process.spawn HOT 12
- Ruby 3.0 support HOT 10
- code hanging attempting to @thread.join HOT 1
- Should work for the M1 chip, but needs to be mapped or smth
- `host_cpu` changes between Ruby 2.7.2 and 2.7.3 HOT 2
- FFI installes but rake test get error HOT 4
- cannot load such file -- ffi (LoadError) HOT 2
- Use with StringIO HOT 1
- posix_spawn is not yet supported on aarch64-linux (aarch64-linux), HOT 2
- posix_spawn is not yet supported on sparc-solaris (sparc-solaris2.11) HOT 1
- I happen to be having this error after even having all both ruby, gem, and even chocolatey handy HOT 2
- Test suite is going to be broken with Ruby 3.3 HOT 1
- differences between macos and linux HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from childprocess.