13

I am new to Erlang and would like to to know how to install third party modules for use in my web application.

Where do you place this files and what sort of commands do you execute?

Ted Karmel
  • 1,046
  • 1
  • 12
  • 20

2 Answers2

5

In my distributive (Arch Linux) this place is /usr/lib/erlang/lib. Of course, you need to build module (make).

Also you can define path for your modules:

demas@arch ~ $ cat .erlang
code:add_pathz("/media/pt_lin/materials/erlang").
ceth
  • 44,198
  • 62
  • 180
  • 289
5

If you wish to install 3rd party libs, like Mochiweb, system wide it's best to set it up under the $ERL_LIBS environment variable. I write a bit about it here and give examples of installing common tools here. It is probably best not to put anything inside Erlang's own code library(/usr/lib/erlang/lib) but the path inside $ERL_LIBS behaves the same way. That is that it adds $ERL_LIBS/**/ebin to the codepath.

However you should really only do things like this while learning the system. To make stable software it's best to include with your app all the dependent code. Also see the answer here for some insight on to why you may wish for this.

Community
  • 1
  • 1
Jon Gretar
  • 5,372
  • 1
  • 23
  • 22
  • In which file is the ERL_LIBS variable located? – Ted Karmel Jun 24 '10 at 00:19
  • Depends on your computer. Check for the files ~/.bash_profile or ~/profile for example. – Jon Gretar Jun 24 '10 at 09:12
  • I suppose using the code module to add the path ( http://www.erlang.org/doc/man/code.html ) would have the same effect as editing the file manually? – Ted Karmel Jun 29 '10 at 13:34
  • Slightly different behavior. You use code:add_path/1 add the specific ebin directory itself as you define it to the code path. The ERLS_LIBS system variable's subdirectories are searched recursively for modules however. – Jon Gretar Jun 29 '10 at 13:42
  • i found three potential files for ERL_LIBS on ubuntu all in /usr/share/base-files : dot.bashrc dot.profile profile Will anyone do or do you suggest one in particular? – Ted Karmel Jun 29 '10 at 15:21
  • No. The usual full path is `/home/UserName/.profile`. The other files you found are just template files used for creating new users I guess. Please note that filenames that begin with `.` in Linux are hidden files. – Jon Gretar Jun 30 '10 at 22:11
  • @JonGretar apparently the pages you linked in your answer are gone. did they move location or are they gone forever? – aurora Jun 14 '15 at 20:17