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 via email

@wayneeseguin
Copy link

Aha! I knew I recalled a no prefix option,

∴ rvm wrapper 1.8.7@ey --no-prefix ey

So that it is clear I am in a different env,

∴ rvm 1.9.2
∴ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]

And we have the desired result,

∴ ey
Usage:
  ey [--help] [--version] COMMAND [ARGS]

Deploy commands:
  ey deploy             # Deploy specified branch, tag, or sha to specified environment.
  ey environments       # List environments for this app; use --all to list all environments.
  ey logs               # Retrieve the latest logs for an environment.
  ey rebuild            # Rebuild specified environment.
  ey rollback           # Rollback to the previous deploy.

Recipes commands:
  ey recipes apply      # Run chef recipes uploaded by the 'recipes upload' command on the specified environment.
  ey recipes upload     # Upload custom chef recipes to specified environment so they can be applied.
  ey recipes download   # Download a copy of the custom chef recipes from this environment into the current directory.

Web commands:
  ey web enable         # Remove the maintenance page for this application in the given environment.
  ey web disable        # Put up the maintenance page for this application in the given environment.

Other commands:
  ey ssh                # Open an ssh session to the master app server, or run a command.

See 'ey help COMMAND' for more information on a specific command.

@drnic
Copy link
Author

drnic commented May 12, 2011 via email

@wayneeseguin
Copy link

If you are not using this for on default ruby installs then that sounds about right.

@wayneeseguin
Copy link

Although this functionality might be useful to add directly into RVM :)

@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