Permalink
Browse files

Add rbenv shims and trusted binstubs to PATH

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

This zsh fix may be necessary for OS users in order to fix a bug:

https://github.com/thoughtbot/laptop/blob/master/mac-components/zsh-fix
  • Loading branch information...
1 parent e0200f0 commit 31b99d97287faf93465ff6e577071b0ef7867a07 @croaky croaky committed Sep 11, 2013
Showing with 13 additions and 3 deletions.
  1. +5 −3 README.md
  2. +8 −0 zshrc
View
@@ -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"
@@ -112,6 +109,11 @@ configuration:
* Adds an `up` alias to fetch and rebase `origin/master` into the feature
branch. Use `git up -i` for interactive rebases.
+[Ruby](https://www.ruby-lang.org/en/) configuration:
+
+* Add trusted binstubs to the `PATH`.
+* Load rbenv into the shell, adding shims onto our `PATH`.
+
Shell aliases and scripts:
* `b` for `bundle`.
View
8 zshrc
@@ -48,6 +48,14 @@ export EDITOR=$VISUAL
# look for ey config in project dirs
export EYRC=./.eyrc
+# load rbenv if available
+if which rbenv &>/dev/null ; then
+ eval "$(rbenv init - --no-rehash)"
+fi
+
+# mkdir .git/safe in the root of repositories you trust
+export PATH=".git/safe/../../bin:$PATH"
+
# aliases
[[ -f ~/.aliases ]] && source ~/.aliases

0 comments on commit 31b99d9

Please sign in to comment.