Help on priv_dir please

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help on priv_dir please

Bob Cowdery-4
Hi,

I'm trying to get gen_serial up and running. I've tracked the problem
down to a line which boils down to code:priv_dir(gen_serial).

This is intending to get the port executable path but returns bad_name.
Why would this call fail?

Thanks

BobC

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Help on priv_dir please

Håkan Mattsson

It looks like the gen_serial app not is in the code path. See what code:get_path() returns.

/Håkan

On Mon, Jun 18, 2018 at 10:22 PM, Bob Cowdery <[hidden email]> wrote:
Hi,

I'm trying to get gen_serial up and running. I've tracked the problem down to a line which boils down to code:priv_dir(gen_serial).

This is intending to get the port executable path but returns bad_name. Why would this call fail?

Thanks

BobC

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Help on priv_dir please

Bob Cowdery-4
In reply to this post by Bob Cowdery-4

This code:priv_dir/1 has me completely baffled. The code for gen_serial will only resolve the directory if I leave it in its original directory and add the ebin to the code path. If I move the files to my own tree it wont give me anything except {error, bad_name}. I've put in the correct directory structure according to the docs, added an Application.app file and tried various names in the call including ?MODULE, the file I am running and the app name. I also added the ebin path to ERL_LIBS to no avail.

There is also some weird thing going on with the paths. Even if I remove the gen_serial original code path from .erlang and then build it from some random directory it still builds that one even though I have a copy in my tree and the code path only points there. Is there some cache somewhere?


On 6/19/2018 8:40 PM, Vance Shipley wrote:
Heh, I just posted about this in another thread. You probably have a problem related to your installed path. It's not enough to set the code path, you need to include the parent directory in the ERL_LIBS environment variable.


On Tue, Jun 19, 2018, 01:52 Bob Cowdery <[hidden email]> wrote:
Hi,

I'm trying to get gen_serial up and running. I've tracked the problem
down to a line which boils down to code:priv_dir(gen_serial).

This is intending to get the port executable path but returns bad_name.
Why would this call fail?

Thanks

BobC

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Help on priv_dir please

Richard Carlsson-3
First, if you run code:which(ModuleName) for any module of the app, it should show you a path that ends in .../APPNAME[-VSN]/ebin/ModuleName.ebin - if it doesn't, code:priv_dir(APPNAME) won't recognize the name as an app and you'll get {error, bad_name}. For example: code:which(lists) -> ".../stdlib-3.4/ebin/lists.beam", code:priv_dir(stdlib) -> ".../stdlib-3.4/priv". This should work even if the priv directory doesn't in fact exist (stdlib does not have one).

Second, for ERL_LIBS to work, it should point out the directory above your set of applications, as in ".../lib", not an ebin directory or a single app directory. Directories under ERL_LIBS that contain an ebin subdirectory will be recognized as apps, and their ebins will be added to the path.

Hope this helps.



        /Richard

2018-06-20 22:58 GMT+02:00 Bob Cowdery <[hidden email]>:

This code:priv_dir/1 has me completely baffled. The code for gen_serial will only resolve the directory if I leave it in its original directory and add the ebin to the code path. If I move the files to my own tree it wont give me anything except {error, bad_name}. I've put in the correct directory structure according to the docs, added an Application.app file and tried various names in the call including ?MODULE, the file I am running and the app name. I also added the ebin path to ERL_LIBS to no avail.

There is also some weird thing going on with the paths. Even if I remove the gen_serial original code path from .erlang and then build it from some random directory it still builds that one even though I have a copy in my tree and the code path only points there. Is there some cache somewhere?


On 6/19/2018 8:40 PM, Vance Shipley wrote:
Heh, I just posted about this in another thread. You probably have a problem related to your installed path. It's not enough to set the code path, you need to include the parent directory in the ERL_LIBS environment variable.


On Tue, Jun 19, 2018, 01:52 Bob Cowdery <[hidden email]> wrote:
Hi,

I'm trying to get gen_serial up and running. I've tracked the problem
down to a line which boils down to code:priv_dir(gen_serial).

This is intending to get the port executable path but returns bad_name.
Why would this call fail?

Thanks

BobC

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions