thoughts.sort()

Notes on managing pyenv, rbenv and nvm using Homebrew

September 07, 2020

Tags: python, ruby, javascript

Notes on managing pyenv, rbenv and nvm using Homebrew

I like package managers. But when I need one for each programming language I use, and when some applications start expecting me to write the version number as part of the package manager name (pip3), I think it’s time to streamline stuff. That is the reason I use version managers to manage my package managers.

A version manager is a specialized package manager that deals with the different versions of the same programming language. One installation of Python 3.8 will have exactly one accompanying installation of pip, so if I have two installations of Python 3.8 and one Python 3.7, that is three package managers I have to keep track of. Using a version manager like pyenv to manage, and switch between individual installations of a programming language (and its accompanying package manager) allows me to think less of the mess that this could otherwise lead to and concentrate on getting my work done.

One level above that, using Homebrew likewise allows me the luxury of not worrying too much about how a particular version manager manages my programming language package managers.

In the following, my notes for how I use Homebrew to manage my version managers for Python, Ruby and Node. And how I use each of these to manage my installed language version.

homebrew (brew.sh)

Installation:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

$ brew ls $ brew install pyenv

pyenv (Github)

$  pyenv versions
* system (set by ~/.pyenv/version)

$ pyenv install --list $ pyenv install 3.8.5

$ pyenv versions
* system (set by ~/.pyenv/version)
  3.8.5
$ pyenv global 3.8.5
$ pyenv versions
  system
* 3.8.5 (set by ~/.pyenv/version)

Remember to add to .zshrc

eval "$(pyenv init -)"

https://github.com/pyenv/pyenv/issues/1446

rbenv (Github)

$ rbenv versions
* system (set by /Users/lasper/.rbenv/version)

$ rbenv install --list

$ rbenv install 2.7.1

$ rbenv init

$ gem env home

$ rbenv global 2.7.1 Sets global version of Ruby used in all shells by writing to ~/.rbenv/version. Overridden .ruby-version in project or by setting environment variable RBENV_VERSION.

$ rbenv shell jruby-1.7.1 Sets shell-specific Ruby version by setting the RBENV_VERSION environment variable in your shell. Overrides application-specific and global version.

$ rbenv shell $ rbenv shell --unset When run without a version number, rbenv shell reports the current value of RBENV_VERSION. You can also unset the shell version:

gem install mdless

nvm (Github)

nvm ls nvm install 8.0.0 nvm --version nvm use 8.0