Skip to content

Instantly share code, notes, and snippets.

@niklas
Created April 8, 2011 12:31
Show Gist options
  • Save niklas/909740 to your computer and use it in GitHub Desktop.
Save niklas/909740 to your computer and use it in GitHub Desktop.
How to run a system command from ruby within a clean bash that has never sourced rvm using a custom ruby version
#!/usr/bin/env ruby
# How to run a system command from ruby within a clean bash that has never sourced rvm using a custom ruby version
# 1) install rvm as the correct user
# 2) do NOT follow the instructions about sourcing and adding this to your .bashrc
# 3) run the following (change the versions accordingly)
ruby_versions = %w(ruby-1.8.7-p330 rbx-head)
ruby_versions.each do |version|
puts ('>' * 20) + " #{version}"
%w(true false).each do |bool|
puts %Q~the following should output "#{bool}"~
p system(%Q~bash -c 'FOO=#{version}; source "/home/niklas/.rvm/scripts/rvm"; rvm use #{version}; ruby -v; echo "echo $FOO"; #{bool}'~)
puts ('=' * 20)
end
puts ('<' * 20)
end
@niklas
Copy link
Author

niklas commented Apr 8, 2011

you may change the source path, but write this without $HOME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment