Skip to content

Load rbenv in zshrc, not zshenv#305

Closed
croaky wants to merge 1 commit intomasterfrom
dc-rbenv-zsh
Closed

Load rbenv in zshrc, not zshenv#305
croaky wants to merge 1 commit intomasterfrom
dc-rbenv-zsh

Conversation

@croaky
Copy link
Contributor

@croaky croaky commented Sep 30, 2014

On Mac OS X, there is a bug where /etc/zshenv's path_helper forces
/usr/bin to the front of the $PATH:

rbenv/rbenv#369

# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
  eval `/usr/libexec/path_helper -s`
fi

This breaks rbenv by always using the system Ruby.

We have fixed this in the past in our Laptop script by moving /etc/zshenv to
/etc/zprofile:

thoughtbot/laptop@c64806e

And more recently, to /etc/zshrc:

https://github.com/thoughtbot/laptop/blame/master/mac

On Yosemite with the version of thoughtbot/dotfiles before this commit, with
rbenv being initialized in ~/.zshenv, the problem returned.

Moving rbenv initialization back to ~/.zshrc fixed the problem.

The official documentation for rbenv also recommends initializing in
~/.zshrc.

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

It also recommends:

export PATH="$HOME/.rbenv/bin:$PATH"

@gylaz
Copy link
Contributor

gylaz commented Oct 1, 2014

Will this cause issues for folks who are pre-Yosemite?

On Mac OS X, there is a bug where `/etc/zshenv`'s `path_helper`
forces `/usr/bin` to the front of the `$PATH`:

rbenv/rbenv#369

    # system-wide environment settings for zsh(1)
    if [ -x /usr/libexec/path_helper ]; then
      eval `/usr/libexec/path_helper -s`
    fi

This breaks rbenv by always using the system Ruby.

We have fixed this in the past in our Laptop script
by moving `/etc/zshenv` to `/etc/zprofile`:

thoughtbot/laptop@c64806e

And more recently, to `/etc/zshrc`:

https://github.com/thoughtbot/laptop/blame/master/mac

On Yosemite with the version of thoughtbot/dotfiles before this commit,
with rbenv being initialized in `~/.zshenv`,
the problem returned.

Moving rbenv initialization back to `~/.zshrc` fixed the problem.

The official documentation for rbenv also recommends initializing in `~/.zshrc`.

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

It also recommends:

    export PATH="$HOME/.rbenv/bin:$PATH"
@croaky
Copy link
Contributor Author

croaky commented Oct 1, 2014

I think it might break rbenv for Tmux users:

https://pgib.me/blog/2013/10/11/macosx-tmux-zsh-rbenv/

They'll want to edit their /etc/zshrc (which we moved in Laptop from /etc/zshenv) to look like this:

# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
  if [ -z "$TMUX" ]; then
    eval `/usr/libexec/path_helper -s`
  fi
fi

@rspeicher
Copy link
Contributor

This re-introduces the problem with Alfred scripts not having access to rbenv that I mentioned in #289.

Does anyone know of a good workaround for that?

@jferris
Copy link
Contributor

jferris commented Oct 2, 2014

Does this also mean the path, etc won't be set correctly from MacVim?

@derekprior
Copy link
Contributor

I don't think we should be making any changes right now for the sake of users of an unreleased OS if its going to break use cases for users of the released OS.

Can we support both uses with some conditional loading in the various initialization scripts?

@derekprior
Copy link
Contributor

Actually, I just pulled the latest dotfiles and also restarted my computer (and thus my terminal that spawns all other terminals) for the first time in a long while only to find that rbenv is not loaded. Something is still sticking /usr/bin on the front.

This did work at one point. I noticed that /etc/zshenv was back, so I tried moving that to /etc/zprofile again and sure enough still broken. Whatever it is is definitely path_helper related because when I sudo chmod -x /etc/libexec/path_helper and restart the shell then rbenv is loaded.

So I pulled down this branch of the dotfiles, reinstated path_helper as executable and restarted. rbenv is loaded. My path is sane. rbenv works inside tmux. pbcopy works inside tmux.

There's one exception: .git/safe path stuff is showing up in my path after rbenv and path_helper related stuff. I think the git safe stuff needs to move back into zshrc too.

@rspeicher
Copy link
Contributor

It might just be best then to revert 6a1bd18.

@derekprior
Copy link
Contributor

Yes, I think that is for the best. See also #303.

derekprior added a commit that referenced this pull request Oct 3, 2014
This reverts commit 6a1bd18. On OS X,
`path_helper` was clobbering our expected PATH value because it is
called in `/etc/zshrc`.

Fixes #303. See discussion there in and in #305.
@derekprior derekprior mentioned this pull request Oct 3, 2014
@derekprior
Copy link
Contributor

Opened #307 to revert, which I think is our best course of action for now.

@croaky
Copy link
Contributor Author

croaky commented Oct 3, 2014

Closing in favor of #307

@croaky croaky closed this Oct 3, 2014
@teoljungberg teoljungberg deleted the dc-rbenv-zsh branch November 14, 2015 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants