Call Ruby 1.8 script from Ruby 2.0 script

I'm not sure if this belongs here or anywhere else (SuperUser?), But anyway:

I have two Ruby scripts that require Ruby 2.0 (A) and the other 1.8 (B). A needs to call B with forked processes. And something like this:

require "fileutils"
require "json"

...

`name_of_B`

B is an executable script using shebang, starting as follows:

#!/Users/user_name/.rvm/rubies/ruby-1.8.7-p374/bin/ruby
require 'rubygems'
require 'json'

...

I use RVMto control my versions of Ruby:

> rvm list
rvm rubies

   ruby-1.8.7-p374 [ i686 ]
   ruby-1.9.3-p448 [ x86_64 ]
=* ruby-2.0.0-p247 [ x86_64 ]

I run A with:

> ruby name_of_A

but in the end:

/Users/jacobevelyn/.rvm/gems/ruby-2.0.0-p247/gems/json-1.8.1/lib/json/ext/parser.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin12.5.0]

, ? , , B , Ruby 2.0, 1.8. (, gem install json 1.8.) , , , ( , , , " t ), .

+4
2

shebang :

#!/Users/user_name/.rvm/wrappers/ruby-1.8.7-p374/ruby

, .

bundler (Gemfile), :

Bundler.with_clean_env do
  ...
end

reset

+1

:

result = `\path\to\ruby_1_8 \path\to\ruby_1_8_script.rb`

ruby ​​ script, . var.


which ruby, ruby ​​ . / dir , ( Ruby 2), . / ( 1.8 script) . , Ruby 1.8. , root (/). RVM, Ruby 1.8, , .


RVM. .., rbenv. , , Ruby 1.8 (, which?) , RVM.

+1

All Articles