Add Path to Erlang Search Path?

随声附和 提交于 2019-12-19 05:36:04

问题


I recently installed Erlang RFC4627 (JSON-RPC) with the debian package. I ran the test server using:

sudo erl -pa ebin

and then at the prompt:

test_jsonrpc:start_httpd().

returned

ok

I tested with http://:5671/ and got the success messages.

When I try to run rabbitmq-http2 however, I get the errors that the readme says are caused by rfc4627's code not being on the erlang search path. How do I put it on the path. I saw something on Dave Thomas's blog which suggested putting the path in the file:

~/.erlang

This didn't seem to work for me (maybe I did it wrong?).


回答1:


The code module is how you manipulate the path within an application.

The flags -pa that you used in starting the Erlang shell actually refer to a function in this module:

add_patha(Dir) -> true | {error, What}

You are right about the .erlang file in your home directory - it is run at start-up time of the shell and you can add in handy paths.

For an application you can start the shell with a batch file that calls something like this:

erl -pa ./ebin ../../lib/some/path/ebin

The flags behaviour of erl is described here.

For more sophisticated path management you need to get familiar with how OTP release management is done (but I suspect that is a while away for you yet).



来源:https://stackoverflow.com/questions/1236950/add-path-to-erlang-search-path

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