Skip to content

Commit

Permalink
Merge pull request aanand#39 from boxofrad/rvm-caveat
Browse files Browse the repository at this point in the history
Add RVM known issues and workaround aanand#32
  • Loading branch information
aanand committed Jan 14, 2013
2 parents 90ba1b0 + 7aca9ef commit 9a0ef11
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ install

$ gem install git-up

RVM user? [read this](https://github.com/aanand/git-up/blob/master/RVM.md).

use
---

Expand Down
53 changes: 53 additions & 0 deletions RVM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Known RVM issues
================

Under RVM some users have [reported](https://github.com/aanand/git-up/issues/32) that running `git-up` works fine, but
running `git up` results in one of many issues, the most common being:

spawn.rb:187:in `_pspawn': Invalid command name (ArgumentError)

cause
-----

The underlying cause is a combination of the way RVM sets the correct
ruby interpreter in the environment, and the way git interprets and
executes `git up`.

When you run `git [some command]` git will first look internally to see
if it can fulfil the command, then it will attempt to "shell out" and run
whatever `git-[some command]` executable it can find in your $PATH.

When git "shells out" all of the environmental variables will be
exposed, and it will be able to find our `git-up` executable in the $PATH.
However because of the way RVM magically sets your ruby interpreter,
when `git-up` is ran `ruby` still points to the non-RVM system default.

workaround
----------

To fix this we need to make sure that RVM gets to do it's business
before `git-up` is ran.

RVM provides a handy way of doing this called "wrappers", so let's
generate a wrapper for git-up like so:

rvm wrapper [ruby-version]@[gemset-name] --no-prefix git-up

Next we need to make sure that git finds our wrapper first, to do this
we can make use of the `/usr/libexec/git-core` directory that git uses
for some of it's own commands.

sudo ln -s $HOME/.rvm/bin/git-up /usr/libexec/git-core/git-up

Finally we need to modify our wrapper to prevent bundler issues when we
are working on ruby projects, so open that file in your favourite
editor, find this line:

exec git-up "$@"

and change it to:

ruby `which git-up` "$@"

This may seem strange, but it bypasses `ruby_noexec_wrapper` which
may cause issues if you are working in a project with a Gemfile.

0 comments on commit 9a0ef11

Please sign in to comment.