Recompiling src file from cowboy prompt gives undefined function compile - erlang

I have my server running with
make run
Then I edited a file. Back in the cowboy terminal I type
(tunnel#127.0.0.1)2> c(clock).
Recompiling /root/tunnel/src/clock.erl
** exception error: undefined function compile:file/2
in function c:compile_and_load/2 (c.erl, line 259)
in call from c:safe_recompile/3 (c.erl, line 235)
(tunnel#127.0.0.1)3> compile(clock).
it seems that the shell recognizes the compile shortcut but it lists it as undefined.
How do I recompile while the server is running?
I also tried erlc src/clock.erl, which gave me a warning using export all but didn't respond with any error.

Related

make on ChicagoBoss failing with escript: exception error: undefined function rebar:main/1

I am trying to install ChicagoBoss based on the instructions here. Now, Make is failing with exception -
=ERROR REPORT==== 14-Dec-2022::11:15:33.605319 ===
beam/beam_load.c(148): Error loading module rebar:
please re-compile this module with an Erlang/OTP 25 compiler
escript: exception error: undefined function rebar:main/1
in function escript:run/2 (escript.erl, line 750)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_em/1
in call from init:do_boot/3
make: *** [compile] Error 127
I have further installed rebar3 using command -
homebrew install rebar3
I am running Erlang OTP/25 in mac. I haven't been able to understand if it's a problem with
rebar3
or
ChicagoBoss
The problem is with ChicagoBoss. It includes a rebar binary that was compiled with Erlang/OTP release 17, but Erlang/OTP release 25 can only use modules compiled with release 21 or later.
The rebar binary starts with the line #!/usr/bin/env escript, meaning that it looks for escript in the PATH. This picks up release 25, causing this problem. You could try installing release 24 or earlier to work around this.
You might find ASDF useful for switching between Erlang versions: https://github.com/asdf-vm/asdf-erlang

I am unable to use `ejabberd_auth` in my **helloworld** project

I am unable to use ejabberd_auth in my helloworld project.
-behaviour(ejabberd_auth).
...
....
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).
With that I get the error warning:
helloworld.erl:15: Warning: behaviour ejabberd_auth undefined
-import(ejabberd_auth, [try_register/3]).
...
....
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).
With this I get:
exception error: undefined function ejabberd_auth:try_register/3
Why am I unable to access ejabberd_auth?
I am using IntelliJ Idea, with the Erlang plugin installed.
Thank you all in advance.
UPDATE:
I'm on Ubuntu 16.04 LTS
I can get you past that error. Here's how...
When I compile a module in the erlang shell, the compiler creates a .beam file in the same directory, which allows me to call functions defined in the module. In your case, if you cd into the directory:
.../ejabberd/ebin
you will see all the ejabberd .beam files, including ejabberd_auth.beam. If you start an erlang shell in that directory, then issue your function call (don't compile anything), you won't get that error anymore.
But, then I get the error:
exception error: undefined function jid:nodeprep/1
in function ejabberd_auth:validate_credentials/3 (src/ejabberd_auth.erl, line 796)
in call from ejabberd_auth:try_register/3 (src/ejabberd_auth.erl, line`
There is no jid.beam file in that directory. But:
~/Downloads/ejabberd$ find . -name jid.beam
./deps/xmpp/ebin/jid.beam
You are going to have to figure out how to compile your module so that all the ejabberd modules are available to your program. See: ejabberd how to compile new module.
I am unable to use ejabberd_auth in my helloworld project.
Are you following a tutorial somewhere?

Can't build OpenCV 3.1 on Windows (using MinGW)

I need to build OpenCV from source, because I want to make modifications to it. So using pre-built binaries is not an option for me. I'm doing this on Windows 8. I do not have MS Visual Studio, and I don't want to use it.
Here is how I reproduce the build error:
I git clone https://github.com/opencv/opencv
I use CMake 3.7.1, press Configure, then press Generate. It seems to work (no errors). I named the output folder opencv/release.
I go to the opencv/release folder, and type mingw32-make.
Eventually, after compiling for a while, it displays the following error message:
Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj
modules\core\src\parallel.cpp:135:43: error: operator '&&' has no right operand
modules\core\src\parallel.cpp: In function 'void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)':
modules\core\src\parallel.cpp:311:52: error: 'parallel_for_pthreads' was not declared in this scope parallel_for_pthreads(range, body, nstripes);
^
modules\core\src\parallel.cpp: In function 'int cv::getNumThreads()':
modules\core\src\parallel.cpp:370:50: error: 'parallel_pthreads_get_threads_num' was not declared in this scope return parallel_pthreads_get_threads_num();
^
modules\core\src\parallel.cpp: In function 'void cv::setNumThreads(int)':
modules\core\src\parallel.cpp:431:46: error: 'parallel_pthreads_set_threads_num' was not declared in this scope parallel_pthreads_set_threads_num(threads);
^
modules\core\CMakeFiles\opencv_core.dir\build.make:990: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj' failed mingw32-make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj] Error 1
Note: I tried to compile both with and without TPP (in the CMake config), and I get the same error message.
Also, I read the other similar questions on StackOverflow and the answers do not help.

Lua Error: "Gnuplot terminal is not set"

In LuaJIT or in the Torch REPL, I run the commands
require 'gnuplot'
gnuplot.figure()
and I get the error "Gnuplot terminal is not set".
I tried using gnuplot.setterm() with some guesses such as 'x11' and 'qt' as arguments, but get the error "gnuplot does not seem to have this term". Is there somewhere I can get a list of terminal emulators/graphics backends available to gnuplot? Or alternatively, are these errors indicative of some other problem?
It turns out that you get this error if you don't have the Gnuplot executable installed.
I didn't check for this problem before because gnuplot.lua (v. 5.1) has an error check for the case of that executable being unavailable - on line 145 - but for some reason it failed to catch the problem.

Not a valid Windows application error in PHPStorm file watcher

Here's what I get in my CMD:
C:\Documents and Settings\Administrator>lessc
lessc: no input files
... (long program output)
C:\Documents and Settings\Administrator>"C:\Documents and Settings\Administrator
\Dane aplikacji\npm\lessc"
lessc: no input files
usage: lessc [option option=parameter ...] <source> [destination]
... (long program output)
C:\Documents and Settings\Administrator>
But when I add a file watcher in my PHPStorm for LESS and specify the program to:
C:\Documents and Settings\Administrator\Dane aplikacji\npm\lessc, I get the following error:
16:52:38 An exception occurred while executing watcher 'LESS'. Watcher has been disabled. Fix it.: Cannot run program "C:\Documents and Settings\Administrator\Dane aplikacji\npm\lessc" (in directory "C:\Documents and Settings\Administrator\Pulpit\bootstrap\css"): CreateProcess error=193, %1 nie jest prawid³ow¹ aplikacj¹ systemu Wi
Why is this happening and how can I fix this?
You seems to forgot how Windows/DOS works ;)
When you trying to execute lessc in Command Shell, Windows will search for such file. If nothing found -- it will search for lessc.exe, lessc.com, lessc.bat, lessc.cmd and so on -- depends on value of PATHEXT environment variable. Just type SET in command prompt and see for yourself.
In PhpStorm (or any other software) where NO command shell is used but command executed DIRECTLY, you have to specify FULL program name, which is lessc.cmd

Resources