Created
May 12, 2011 15:10
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
Author
drnic
commented
May 12, 2011
via email
how do I get to keep the "ey" CLI name? I still want it to be "ey", I just want it to be installed in a known-working ruby version, and might as well be in its own gemset.
##
Dr Nic Williams
Engine Yard, VP Technology
SV Ruby Club, President
http://engineyard.com
http://drnicwilliams.com
cell +1 (415) 860-2185
…On Thursday, May 12, 2011 at 9:22 AM, wayneeseguin wrote:
Now that I understand what you are doing...
While obviously there is room for improvement int the generated 'ey_bin' naming,
this is already built into RVM,
∴ rvm wrapper ***@***.*** 18 ey
∴ 18_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.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/968697
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.
So I keep the installer step, and then run the "rvm wrapper 1.8.7@ey --no-prefix ey" command instead of creating my own wrapper?
##
Dr Nic Williams
Engine Yard, VP Technology
SV Ruby Club, President
http://engineyard.com
http://drnicwilliams.com
cell +1 (415) 860-2185
…On Thursday, May 12, 2011 at 9:26 AM, wayneeseguin wrote:
Aha! I knew I recalled a no prefix option,
∴ rvm wrapper ***@***.*** --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.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/968697
If you are not using this for on default ruby installs then that sounds about right.
Although this functionality might be useful to add directly into RVM :)
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
I wasn't fully understanding what you were getting at until you did this gist.
And now you get the gist of what I was on about. Hazaar for gists! :)
"You get my drift?"
"No, but I do get your gist..."
;)
This is hard to ingist.
Cheers
Nic
http://engineyard.com
http://drnicwilliams.com
+1 (415) 322 9556
Engine Yard: Successful Rails Apps through Orchestration
…On May 12, 2011, at 5:50 PM, ***@***.*** wrote:
"You get my drift?"
"No, but I do get your gist..."
;)
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/968697
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment