How It Works
At a high level, elmenv intercepts Elm commands using shim
executables injected into your
PATH, determines which Elm version
has been specified by your application, and passes your commands along
to the correct Elm installation.
elmenv works by inserting a directory of shims at the front of your
Through a process called rehashing, elmenv maintains shims in that
directory to match every Elm command across every installed version
and so on.
Shims are lightweight executables that simply pass your command along
to elmenv. So with elmenv installed, when you run, say,
operating system will do the following:
- Search your
PATHfor an executable file named
- Find the elmenv shim named
elmat the beginning of your
- Run the shim named
elm, which in turn passes the command along to elmenv
Choosing the Elm Version
When you execute a shim, elmenv determines which Elm version to use by reading it from the following sources, in this order:
ELMENV_VERSIONenvironment variable, if specified. You can use the
elmenv shellcommand to set this environment variable in your current shell session.
.elm-versionfile found by searching the directory of the script you are executing and each of its parent directories until reaching the root of your filesystem.
.elm-versionfile found by searching the current working directory and each of its parent directories until reaching the root of your filesystem. You can modify the
.elm-versionfile in the current working directory with the
~/.elmenv/versionfile. You can modify this file using the
elmenv globalcommand. If the global version file is not present, elmenv assumes you want to use the "system" Elm—i.e. whatever version would be run if elmenv weren't in your path.
This will get you going with the latest version of elmenv and make it easy to fork and contribute any changes back upstream.
Check out elmenv into
$ git clone --recurse-submodules https://github.com/sonnym/elmenv.git ~/.elmenv
$PATHfor access to the
$ echo 'export PATH="$HOME/.elmenv/bin:$PATH"' >> ~/.bash_profile
Ubuntu Desktop note: Modify your
Zsh note: Modify your
~/.zshrcfile instead of
elmenv initto your shell to enable shims and autocompletion.
$ echo 'eval "$(elmenv init -)"' >> ~/.bash_profile
Same as in previous step, use
~/.bashrcon Ubuntu, or
Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if elmenv was set up:
$ type elmenv #=> "elmenv is a function"
If you've installed elmenv manually using git, you can upgrade your installation to the cutting-edge version at any time.
$ cd ~/.elmenv $ git pull $ git submodule foreach $(git submodule update --init --recursive)
To install a Elm version for use with elmenv, run
elmenv install with the
exact name of the version you want to install. For example,
elmenv install 0.14.1
Elm versions will be installed into a directory of the same name under
~/.elmenv/versions. It is also possible install the
master branch of
elm. The installation is directly from source, so it is necessary to have
an up to date haskell and cabal setup.