ahoward / systemu

univeral capture of stdout and stderr and handling of child process pid for windows, *nix, etc.
Other
126 stars 33 forks source link

systemu 2.6.5 breaks cli ruby scripts with inline bundle #49

Open BrackXs opened 5 years ago

BrackXs commented 5 years ago
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'systemu'
end
puts 1
status, stdout, stderr = systemu 'date'
p [ status, stdout, stderr ]
puts 2

generates

1
/home/.../Gemfile not found
/home/.../Gemfile not found
no ruby in PATH/CONFIG
sh: 1: nil: not found
/home/.../.rvm/gems/ruby-2.4.0/gems/systemu-2.6.5/lib/systemu.rb:97:in `rescue in block (3 levels) in systemu': systemu: Error - process interrupted! (RuntimeError)

    from /home/.../.rvm/gems/ruby-2.4.0/gems/systemu-2.6.5/lib/systemu.rb:90:in `block (3 levels) in systemu'
damphyr commented 5 years ago

Can confirm. Let's see if I can fix as well.

damphyr commented 5 years ago

Adding bundler inline breaks the detection of the ruby runtime in systemu (those two /home/.../Gemfile not foundlines are the two system calls in lines 38 and 41. Both fail so systemu says it can't find a ruby.

Basically this happens without systemu being involved. I can reduce the problem to calling ruby with system after requiring bundler/inline:

require 'bundler/inline'
gemfile do
    source 'https://rubygems.org'
end
c = ::RbConfig::CONFIG
ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
system(ruby, '-e', '42')

I don't see how I can work around this yet.

damphyr commented 5 years ago

Posted an issue for bundler https://github.com/bundler/bundler/issues/7159