I try to set up ChicagoBoss with all it's dependencies to ERL_LIBS environment variable. I got ChicagoBoss, compiled it with ./rebar get-deps && ./rebar compile, now i have ChicagoBoss in /home/user/ChicagoBoss directory and it's dependencies in /home/user/ChicagoBoss/deps directory. I want to add it to ERL_LIBS. I put to my .bashrc file following line:

export ERL_LIBS=/home/user/ChicagoBoss/:/home/user/*/deps/*/

But when i try something from ChicagoBoss dependencies, ranch application for example with:

application:start(ranch).

I got error:

{error,{"no such file or directory","ranch.app"}}

Thank you.

有帮助吗?

解决方案

The ERL_LIBS environment variable has no notion of wildcards. When you start the erl with an argument like -pa deps/*/ebin, your shell is expanding the wildcard. You need to manually add every library path (the path to the application, not its ebin directory!) to ERL_LIBS.

To simplify this process we can use Python:

import glob
print ':'.join(glob.glob('/home/user/*/deps/*/'))

其他提示

I had an identical error with a simple application. It turned out that there was a missing 'dep' directory in the main application directory: ranch was installed there. I don't know why it was missing in my case, but I solved it by copying that directory from another working ranch application.

EDIT: Interestingly, I had got a message compiling saying: "Dependency not available: ranch-.* ({git,"git://github.com/extend/ranch.git", "master"})" which must have been a warning about the missing 'dep' top-level directory.

ERL_LIBS can simply point to the parent directory where all your dependencies projects reside. If your projects follow the Erlang Project directory convention ( yourproject/src, yourproject/ebin, yourproject/include ) then Erlang will dynamically associate the ebin and include from those projects to your context.

Example

/place/Project1

/place/Project1/ebin/...
/place/Project1/include/...
/place/Project1/deps/...
/place/Project1/deps/DependencyProject2...
/place/Project1/deps/DependencyProject3...

As it canbe seen above, /place/Project1/deps is the container for other sub-projects ( dependencies ). In this case if you can run your application as

erl env ERL_LIBS "/place:/place/Project1/deps". This will include all related projects ( Project1, DependencyProject2 and DependencyProject3 ) in your runtime context.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top