Skip to content

Commit

Permalink
Add rbenv shims and 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

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
Dan Croak committed Jan 23, 2014
1 parent e0200f0 commit 31b99d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Original file line 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: Your `~/.zshrc.local` might look like this:


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

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


Expand Down Expand Up @@ -112,6 +109,11 @@ configuration:
* Adds an `up` alias to fetch and rebase `origin/master` into the feature * Adds an `up` alias to fetch and rebase `origin/master` into the feature
branch. Use `git up -i` for interactive rebases. 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: Shell aliases and scripts:


* `b` for `bundle`. * `b` for `bundle`.
Expand Down
8 changes: 8 additions & 0 deletions zshrc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export EDITOR=$VISUAL
# look for ey config in project dirs # look for ey config in project dirs
export EYRC=./.eyrc 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 # aliases
[[ -f ~/.aliases ]] && source ~/.aliases [[ -f ~/.aliases ]] && source ~/.aliases


Expand Down

0 comments on commit 31b99d9

Please sign in to comment.