ejabberctl live can't start appmon, error is: couldn't connect to display ":0"

Hi,
I'm stuck in this weird situation:
I start ejabberd like this:
$sudo ejabberdctl live
And it does work:

=INFO REPORT==== 22-Jun-2011::17:56:10 ===
I(<0.40.0>:ejabberd_app:74) : ejabberd 3.0.0-alpha-x is started in the node ejabberd@localhost

=PROGRESS REPORT==== 22-Jun-2011::17:56:10 ===
application: ejabberd
started_at: ejabberd@localhost

(ejabberd@localhost)1>

but when I start appmon, error occurs:

(ejabberd@localhost)1> appmon:start().
No protocol specified
Application initialization failed: couldn't connect to display ":0"
No protocol specified
Error in startup script: couldn't connect to display ":0"
while executing
"load /usr/lib/libtk8.5.so.0 Tk"
("package ifneeded Tk 8.5.9" script)
invoked from within
"package require Tk 8.3"
(file "/usr/local/lib/erlang/lib/gs-1.5.13/priv/gstk.tcl" line 7)

The weirdest thing bothers me is that there is no problem when I just start erl in the shell and then start appmon.

$ erl
Erlang R14B03 (erts-5.8.4) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.4 (abort with ^G)
1> appmon:start().
{ok,<0.34.0>}
2>

BTW, I installed KDE two days ago, it seems that the switch from GNOME to KDE cause this error, because there was nothing wrong with ejabberd live and appmon before that installation.
So can anybody help me? My enviroment is Ubuntu 11.04, KDE 4.6.2

Best regards.

Maybe the erlang node runs as

Maybe the erlang node runs as root:

(ejabberd@localhost)1> os:cmd("whoami").
"root\n"

and it now doesn't have access to the X system in your machine.

How you can give access for your X to the "root" user: add in your $HOME/.bashrc file this line:

export XAUTHORITY=/home/`whoami`/.Xauthority

An alternative is to run the erlang node as your user:

$ whoami
badlop
$ ./configure --enable-user=badlop
$ make
$ sudo make install
$ ejabberdctl live
(ejabberd@localhost)1> os:cmd("whoami").
"badlop\n"
(ejabberd@localhost)2> appmon:start().
{ok,<0.558.0>}
(ejabberd@localhost)3> 

Thank you, badlop. This

Thank you, badlop. This method works correctly.

Syndicate content