code-quality

Making Rbenv Work With Zsh

Making Rbenv Work With Zsh

rbenvrubyshell
Making Rbenv Work With Zsh

I have heard lots of great things about zsh. I had already installed zsh in my system and tried out few times.

But I had not yet thought of using it as my default shell. Today, I decided to switch my default shell to zsh.

Every new adoption comes with some learning experience. Zsh has already come up with first challenge for me:

My rbenv stopped working!

I would set my default ruby version to 2.3.0 and switch to some project folder and do ruby -v and it would show 1.9.3-p374 as my ruby versions.

I copied some of my config from .bashrc to .zshrc with the hope to solve this problem.

# rbenv settings
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

But then I started getting error everytime I opened new terminal:

/home/fleck/.rbenv/libexec/../completions/rbenv.bash:16: command not found: complete

I searched a bit and found that I need to update my rbenv settings from eval "$(rbenv init -)" to eval "$(rbenv init - zsh)" in order to work normally.

With this change, My rbenv started working normally. Here is how my rbenv settings in .zshrc file looks like currently:

# rbenv settings
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

Hope this helps you too.

Happy Learning!

References:

  1. rbenv with zsh
About the author

Prakash Poudel Sharma

Engineering Manager · Product Owner · Varicon

Engineering Manager at Varicon, leading the Onboarding squad as Product Owner. Eleven years of building software — first as a programmer, then as a founder, now sharpening the product craft from the inside of a focused team.

Keep reading

More on this

Join the conversation0 comments

What did you take away?

Thoughts, pushback, or a story of your own? Drop a reply below — I read every one.

Comments are powered by Disqus. By posting you agree to theirterms.

0:000:00