1

I have read the thread here: Erlang VM -s argument misbehaving and have been troubleshooting to no avail.

When I run the erlang vm without the -s flag, my function works:

bridge_sup:start_link().

   Bridge Supervisor Initializing
   [warning] ClientId is NULL!
   [warning] ClientId is NULL!
   Success
   Success

However, if I have the -s flag set, when my function goes on to call another function emqttc:start_link(...) it never returns:

Bridge Supervisor Initializing
   [warning] ClientId is NULL!
   [warning] ClientId is NULL!

I can verify that it is not just a print problem because the program I am connecting to receives no signal.

What could possibly be causing this in the Erlang VM? I have also tried using eval to the same effect. Here is the ./run code:

erl -pa ebin -pa deps/*/ebin

Thank you in advance!

Code Wiget
  • 1,540
  • 1
  • 23
  • 35
  • It would help if you described _exactly_ the sequence of steps that you do when the program works, and correspondingly what you do when it doesn't. There are currently too many unknowns. – RichardC Aug 18 '17 at 19:33
  • @RichardC please see my answer. I believe the problem is that there was no .app file. – Code Wiget Aug 18 '17 at 20:12
  • Yes, but now you are starting the program in a different way, so it could be useful to figure out why it didn't work before. Typically, if it works from the interactive shell, it should work through -s. Is there for example anything that might require the program to be running as a started application? – RichardC Aug 19 '17 at 20:20

2 Answers2

0

Could be a startup order problem. Specifying a command to run using -s (or -run or -eval) means that it starts very quickly, while parts of the system may still be starting up in the background. Try adding a sleep at the start of your function and see if it changes anything. In that case, try to figure out what depends on the order.

RichardC
  • 10,412
  • 1
  • 23
  • 24
  • just threw in a 1s & 5s wait and it didn't help. I'm running a gen_server and what it seems like is that none of my handle_info or handle_cast or call functions are being run. For example, I run a connect command, which works, but my gen_server waits for a response in the form of {client, Pid, connected}, State and never gets it. It seems like the message passing is messed up. – Code Wiget Aug 18 '17 at 13:44
0

I am using Erlang version 19.2. I am not sure if this is a bug in this version, or it is a requirement to start a program, but I added a .app.src file and added "-eval 'application:start(myprog)'" and the program will now start!

Note that it did not start with -s, -eval, or any of that without the app.src file and without application:start

Code Wiget
  • 1,540
  • 1
  • 23
  • 35