In elixir, How do i install packages globally?

家住魔仙堡 提交于 2019-12-08 15:13:12

问题


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.


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/33548079/in-elixir-how-do-i-install-packages-globally

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!