Can I use mix to install some packages globally? I'd like a behaviour like npm
's global option or gem
's install - it could be useful for packages I use everywhere like csv
or yaml
.
There is no such thing in Elixir, you always use dependencies in the context of a project. Solutions like archives or escripts are meant to solve specific problems, they do not allow package sharing between projects.
However, there is no need to worry about sharing frequently used packages. Hex, the package manager, already cache those and it will take care of handling it for you.
Certain packages will provide an archive file that you can install globally.
http://elixir-lang.org/docs/v1.1/mix/Mix.Tasks.Archive.Install.html
For example Phoenix:
mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.0.3/phoenix_new-1.0.3.ez
This allows access to the mix phoenix.new
task globally. There is not anything specific for allowing the installation of libraries that are available in all your mix projects though.
For Elixir scripts, you can virtually install global packages by using erun
.
By compiling erun
with your dependencies, you can run
$ erun foo.exs
(erun
is just an escript.)
https://github.com/s417-lama/erun
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With