Skip to content

Instantly share code, notes, and snippets.

@drnic
Created May 12, 2011 15:10
Show Gist options
  • Save drnic/968697 to your computer and use it in GitHub Desktop.
Save drnic/968697 to your computer and use it in GitHub Desktop.
Installs a gem in a specific RVM ruby/gemset, and creates wrapper script to always use that specific ruby/gemset.
#!/usr/bin/env ruby
# Installs a gem in a specific RVM ruby/gemset, and helps you create
# an alias to a CLI/bin script to always use that gemset.
# Wonderfully useful for utility scripts (engineyard's ey or github-gem's gh)
#
# USAGE:
# freeze_gem_cli engineyard ey
# freeze_gem_cli github gh ruby-1.8.7p334
#
# Then add the suggested aliases to your .bash_profile
gem_name, gem_executable, rvmruby = ARGV[0..2]
puts "USAGE: freeze_gem_cli GEMNAME [EXEC] [RVMRUBY]" and exit 1 unless gem_name
gem_executable ||= gem_name
gemset_name = "#{gem_name}-cli-#{gem_executable}"
rvmruby ||= `rvm current`.strip
rvmgemset = "#{rvmruby}@#{gemset_name}"
def run_cmd(cmd)
puts cmd
puts `#{cmd}`
end
run_cmd "rvm --create #{rvmgemset} exec gem install #{gem_name}"
run_cmd "rvm wrapper #{rvmgemset} --no-prefix #{gem_executable}"
@drnic
Copy link
Author

drnic commented May 12, 2011

I think its a useful addition into rvm; I wanted to spike out the idea. I was struggling to get you to do it :P

@wayneeseguin
Copy link

I wasn't fully understanding what you were getting at until you did this gist.

@drnic
Copy link
Author

drnic commented May 12, 2011

And now you get the gist of what I was on about. Hazaar for gists! :)

@wayneeseguin
Copy link

"You get my drift?"
"No, but I do get your gist..."
;)

@drnic
Copy link
Author

drnic commented May 13, 2011 via email

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