I've been working through the Erlang tutorials in Seven Languages in Seven Weeks using Erlide for eclipse and for the most part all seemed to be ok until i got to the concurrency section.
In this section, the author walks through a simple example
loop() ->
receive
"casa" ->
io:format("house~n"),
loop();
"blanca" ->
io:format("white~n"),
loop();
_ -> io:format("no comprendo~n"),
loop()
end.
When running as suggested by the book i should be able to send messages with Pid ! "someStuff". However when running this, nothing is returned and the debugger requires i kill the process before any activity resumes.
Here's an example of the console. You'll see when i send the message, nothing is returned.
Eshell V5.10.4
(ErlangDay3#Jeff-PC)1> Pid = spawn(fun translate:loop/0).
<0.202.0>
(ErlangDay3#Jeff-PC)2> Pid ! "casa".
Pid ! "hello?".
WhatJustHappened.
This all seems to run perfectly through the command line directly with Eshell (without eclipse and erlide). Could i have missed some configuration somewhere? I'm now completely stumped. I realize that maybe SO is not the best place for a question like this, however i've completely exhausted my google-fu and it doesn't appear that erlide has any forum presence.
Thanks for any and all advice.
In case it helps anything i'm running windows 7 and eclipse (STS, 3.3.0), with Erlang 5.10.4 (R16B03-1)
Thanks for the report!
This was a bug that I was hunting unsuccessfully since a while back, but now I managed to find and fix it. Please try the latest nightly build from http://download.erlide.org/update/nightly
Related
Getting back to Erlang and I noticed that I am unable to run any of the supporting frameworks that have their own user guides, such as EUnit, Common Test, leex, yecc, Dyalizer, Typer etc.
According to the Common Test User's Guide, "the Common Test application is installed with the Erlang/OTP system" and that "no extra installation step is required". I assume that this is true to the others as well and I'm sure that I'm missing something basic.
#aronisstav hit the nail on the head with his comment about "a misconception caused by the shell's autocomplete function which is based on what is already loaded". To quote him again, the correct answer is:
All these tools have some suitable Erlang "entry point" function and
calling this function should work (assuming you are not starting your
node/shell in embedded mode).
Gave these below a try and they worked (I guess I was just an idiot):
6> leex:file("./program.erl").
./program.erl.xrl: no such file or directory
error
7> dialyzer:gui().
To have the shell autocomplete working, simply load the modules by using code:load_file/1 or l(Module) in the erl shell:
$ erl
1> code:load_file(ct).
{module,ct}
2> l(dialyzer).
{module,dialyzer}
I run a small private group of users on an XMPP server and recently I needed to write a custom module. To start write a custom module, I followed this [tutorial][1].
As I have not written a custom module before and being at an low intermediate level with Erlang I decided to go for the basics - following Jack Moffits mod_sunshine.erl example as well as Anders Conbere's examples.
I am running ejabberd-13.12 community edition on Ubuntu LTS 12.04. For the life of me I can not get mod_sunshine to work or even just a basic skeletal module to work (see below mod_test.erl).
I compile to a beam file, I edit the ejabberd.cfg file (in ejabberd-13.12 it is ejabberd.yml). I restart and get the following error:
gen_mod:start_module:78 Problem starting the module mod_sunshine for
host <<"xmpp1.xxxxx.com">>
options: []
error: undef
I have found very little on the internet resolving this problem. Maybe there are about a half dozen posts out there with the gen_mod:start_module:78 error but no real solutions.
I have wasted 2 days trying to figure this out. Even trying on another server using ejabberd-2.1.10 but no dice.
Below is the barest custom module I've tested but still get the same error.
-module(mod_test).
-behaviour(gen_mod).
-export([start/2, stop/1]).
start(_Host, _Opt) -> ok.
stop(_Host) -> ok.
Can anyone help me please?. Thanks in advance!!
I feel like I'm missing something stupid obvious, but I've looked all over and can't find the answer to my question.
Suppose I have an application release that I've built with rebar and I start it a la
rel/my_app/bin/my_app start
I let it happily go about its business for a while, and then I want to attach a console to check on things, so I do
rel/my_app/bin/my_app attach
and get a shell. I muck around, and then when I'm done I want to quit the shell but leave the application running. If I do ^G q or q()., it brings down the entire application.
I've also played with starting the app with +Bi to stop it from allowing someone to accidentally close it, but then how does one even exit an attached shell at all?
I don't use rebar, I've never understood what problem it was meant to solve, but I assume when you "attach" you are doing the same thing as running to_erl. To exit in from this you type control-D (EOF).
CTRL-D should get you out and keep the app running.
Eshell V10.7 (abort with ^G)
$ Ctrl^G
$ q
here,you can quit the remote console
If it's an ordinary remote shell, hitting Ctrl-C twice ought to do the trick.
Okay here's my problem.
I type in "rails s" and then my terminal won't let me type in any commands. So I have to start a new terminal window, which is pretty annoying.
On the other hand I can type in "rails s -d" which detaches, and then it's a pain to stop the server when I need to. (Instead of using control+c, I have to find the PID and use kill -9 PID)
I'm not a professional, so if anyone has any advice it would be much appreciated, thank you!
I don't believe there is a way to do the thing you are specifically asking for.
However, I use Iterm2 which allows me to open multiple terminal windows in one window, either by splitting my iTerm2 window or by creating multiple tabs. That way I can just make the terminals that are holding rails server and my development.log tail very small unless something interesting happens in them.
I use screen, you can also use TMUX but they are window managers in terminal and you can create multiple windows in same terminal window :)
Read up on them at WikiVS as that might help you :)
http://www.wikivs.com/wiki/Screen_vs_tmux
Screen: http://www.gnu.org/software/screen/
TMUX: http://tmux.sourceforge.net/
So you can easily switch and maintain same terminal window. You can't obviously use the EXACT same window that rails server running but it's close enough without having to do the searching for the PID.
You can type: rails s &. I'm not sure if this is what you meant.
I'm trying to start an Erlang app that is failing. All I see in the shell is:
=INFO REPORT==== 7-Jan-2010::17:37:42 ===
application: ui
exited: {shutdown,{ui_app,start,[normal,[]]}}
type: temporary
How can I get Erlang to give me more information as to why the application is not starting? There currently is no other output in the shell.
You could try launching the shell with more logging support:
erl -boot start_sasl
this might get give a bit more details.
There is a patch (tp/supervisor-pass-on-errors) that was included in release R16B. This patch makes exit reasons appear in application stop log messages, which thus become much more useful than the {shutdown,{ui_app,start,[normal,[]]}}-style messages we've had until now.
This is the entry in the README:
OTP-10490 == stdlib ==
If a child process fails in its start function, then the
error reason was earlier only reported as an error report
from the error_handler, and supervisor:start_link would only
return {error,shutdown}. This has been changed so the
supervisor will now return {error,{shutdown,Reason}}, where
Reason identifies the failing child and its error reason.
(Thanks to Tomas Pihl)
It is a pain, but the way I do it is the old fashioned way, by writing io:format's into the start function of the application (ie the code of the module with the behaviour of application) and working out which line fails :(
Sometimes brute force and ignorance is your only man...