Skip to content

Commit

Permalink
Load rbenv and add trusted binstubs to $PATH
Browse files Browse the repository at this point in the history
Our expected way of managing Rubies is with rbenv:

https://github.com/thoughtbot/laptop/blob/master/common-components/ruby-environment

This commit loads rbenv in `zshrc` as recommended by the rbenv docs:

https://github.com/sstephenson/rbenv#basic-github-checkout

Assuming the binstubs for a project are in the local bin/ directory, we
can even go a step further to add the directory to shell $PATH so that
rspec can be invoked without the bin/ prefix:

    export PATH="./bin:$PATH"

Doing so on a system that other people have write access to (such as a
shared host) is a security risk:

rbenv/rbenv#309

The `.git/safe` convention addresses the security problem:

https://twitter.com/tpope/status/165631968996900865
  • Loading branch information
Dan Croak committed Jan 23, 2014
1 parent e0200f0 commit 2a36c65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ Your `~/.gitconfig.local` might look like this:

Your `~/.zshrc.local` might look like this:

# load rbenv
eval "$(rbenv init -)"

# recommended by brew doctor
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

Expand Down
8 changes: 8 additions & 0 deletions zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export EDITOR=$VISUAL
# look for ey config in project dirs
export EYRC=./.eyrc

if which rbenv &>/dev/null ; then
# load rbenv
eval "$(rbenv init - --no-rehash)"

# mkdir .git/safe in the root of repositories you trust
export PATH=".git/safe/../../bin:$PATH"
fi

# aliases
[[ -f ~/.aliases ]] && source ~/.aliases

Expand Down

0 comments on commit 2a36c65

Please sign in to comment.