Why doesn't rebar compile my files? - erlang

It's been a while since I've done any Erlang and I wanted to get back into it and use rebar to do it. I have a simple module-test combo that I've verified compiles okay, but when I try and compile it through rebar, nothing happens:
PS C:\Users\Magnus\Programming\binlog_parser_demo> rebar co -vv
DEBUG: Consult config file "c:/Users/Magnus/Programming/binlog_parser_demo/rebar.config"
DEBUG: Rebar location: "c:/Users/Magnus/Programming/rebar/rebar"
DEBUG: is_rel_dir(C:/Users/Magnus/Programming/binlog_parser_demo) -> false
DEBUG: Available deps: []
DEBUG: Missing deps : []
DEBUG: Plugins requested while processing C:/Users/Magnus/Programming/binlog_parser_demo: []
DEBUG: Predirs: []
==> binlog_parser_demo (compile)
DEBUG: Matched required ERTS version: 7.0 -> .*
DEBUG: Matched required OTP release: 18 -> .*
DEBUG: Min OTP version unconfigured
DEBUG: Postdirs: []
PS C:\Users\Magnus\Programming\binlog_parser_demo> ls -r
Directory: C:\Users\Magnus\Programming\binlog_parser_demo
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/9 15:42 src
d---- 3/9 14:42 test
Directory: C:\Users\Magnus\Programming\binlog_parser_demo\src
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 3/9 14:43 2293 binlog_parser_demo.erl
Directory: C:\Users\Magnus\Programming\binlog_parser_demo\test
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 3/9 14:51 2662 binlog_parser_demo_tests.erl
What am I doing wrong? The file structure is what I got when I ran the template rebar create template=simplemod modid=binlog_parser_demo (and replaced the generated files with my old prewritten ones). I've verified that erlc is in the path and available and that erlc can compile the files okay when run independently.

You need to add a .app.src file to your src directory to define your application. The contents might look something like the following, but you'll need to adjust it to make it work properly for your case.
{application, binlog_parser, [
{description, "Binlog Parser"},
{vsn, "0.1"},
{registered, []},
{applications, [kernel, stdlib]}
]}.
See the rebar "Getting Started" docs for more information.

Related

Erlang Hello World using Bazel as a build system

I want to build an Erlang hello world example using rules_erlang on Ubuntu 22.04.
My setup looks like this:
BUILD.bazel
load("#rules_erlang//:erlang_app.bzl", "erlang_app", "test_erlang_app")
load("#rules_erlang//:xref.bzl", "xref")
load("#rules_erlang//:dialyze.bzl", "dialyze", "plt")
load("#rules_erlang//:ct.bzl", "ct_suite", "assert_suites")
APP_NAME = "hello_world"
APP_VERSION = "0.1.0"
erlang_app(
app_name = APP_NAME,
app_version = APP_VERSION,
)
src/hello_world.erl
-module(hello_world).
-compile(export_all).
hello() ->
io:format("hello world~n").
WORKSPACE.bazel
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_skylib",
sha256 = "af87959afe497dc8dfd4c6cb66e1279cb98ccc84284619ebfec27d9c09a903de",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz",
],
)
load("#bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
http_archive(
name = "rules_erlang",
sha256 = "5e59800ecc786d5375951028c959c6e6275c94eff2a52f5d53ccb1ad8b2ea20a",
strip_prefix = "rules_erlang-3.8.4",
urls = ["https://github.com/rabbitmq/rules_erlang/archive/refs/tags/3.8.4.zip"],
)
load(
"#rules_erlang//:rules_erlang.bzl",
"erlang_config",
"rules_erlang_dependencies",
)
erlang_config()
rules_erlang_dependencies()
load("#erlang_config//:defaults.bzl", "register_defaults")
register_defaults()
The code can also found here.
When I execute bazel build //... I get
ERROR:
/home/vertexwahn/.cache/bazel/_bazel_vertexwahn/b5f945f94177a8ffa6ac0f7108dfc1cd/external/erlang_config/external/BUILD.bazel:12:16:
Validating otp at /usr failed: (Exit 1): bash failed: error executing
command /bin/bash -c ... (remaining 1 argument skipped)
Use --sandbox_debug to see verbose messages from the sandbox and
retain the sandbox build root for debugging Erlang version mismatch
(Expected UNKNOWN, found 24.2.1)
Any hints to get this working are welcome!
To run it, you can declare a shell rule in your BUILD.bazel, for instance:
load("#rules_erlang//:shell.bzl", "shell")
shell(
name = "repl",
deps = [":erlang_app"],
extra_erl_args = ["-eval", "'hello_world:hello()'"],
)
and then you could bazel run :repl.
Or, you could use an escript rule if you change hello_world.erl so that it exports main/1 instead of hello:
load("#rules_erlang//:escript.bzl", "escript_archive")
escript_archive(
name = "hello_world",
app = ":erlang_app",
)
hello_world.erl:
-module(hello_world).
-export([main/1]).
main(_) ->
io:format("hello world~n").
and run with bazel run :hello_world
bazel build //... --sandbox_debug
gave me
compile: warnings being treated as errors
hello_world.erl:2:2: export_all flag enabled - all functions will be exported
With -export([hello/0]). instead of -compile(export_all). it works
-module(hello_world).
-export([hello/0]).
hello() ->
io:format("hello world~n").
❯ bazel build //...
INFO: Analyzed 3 targets (0 packages loaded, 0 targets configured).
INFO: Found 3 targets...
INFO: Elapsed time: 0,326s, Critical Path: 0,25s
INFO: 2 processes: 1 internal, 1 darwin-sandbox.
INFO: Build completed successfully, 2 total actions

Vaadin upgrade 22.0.2 to 23.0.3 failed

I upgraded my application (i.e. I adjusted the version number in the pom) from Vaadin v22.0.2 (using which it built and ran perfect) to v23.0.3 and the below is what I get. The issue is again something with node but what is wrong here?
run maven build:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.example:my-app >------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from webjars: https://dl.bintray.com/webjars/maven/org/webjars/npm/mobile-drag-drop/maven-metadata.xml
[WARNING] Could not transfer metadata org.webjars.npm:mobile-drag-drop/maven-metadata.xml from/to webjars (https://dl.bintray.com/webjars/maven): Transfer failed for https://dl.bintray.com/webjars/maven/org/webjars/npm/mobile-drag-drop/maven-metadata.xml
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # my-app ---
[INFO] Deleting U:\Documents\eclipse\workspace_Vaadin\my-app\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # my-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 85 source files to U:\Documents\eclipse\workspace_Vaadin\my-app\target\classes
[INFO]
[INFO] --- vaadin-maven-plugin:23.0.3:prepare-frontend (default) # my-app ---
[INFO] Project node version 16.13.0 is older than 16.14.0. Using node from C:\Users\xyz\.vaadin.
[INFO] Reflections took 1690 ms to scan 161 urls, producing 9229 keys and 45288 values
[INFO] Added 9 default dependencies to main package.json
[INFO] Copying frontend resources from jar files ...
[INFO] Visited 161 resources. Took 424 ms.
[INFO]
[INFO] --- vaadin-maven-plugin:23.0.3:build-frontend (default) # my-app ---
[INFO] Reflections took 1091 ms to scan 161 urls, producing 9229 keys and 45288 values
[INFO] Scanning classes to find frontend configurations and dependencies...
[INFO] Visited 4053 classes. Took 3945 ms.
[INFO] Visited 142 classes. Took 87 ms.
[INFO] Unable to determine version information. No vaadin_versions.json found
[INFO] Running `npm install` to resolve and optionally download frontend dependencies. This may take a moment, please stand by...
[INFO] Project node version 16.13.0 is older than 16.14.0. Using node from C:\Users\xyz\.vaadin.
[INFO] using 'C:\Users\xyz\.vaadin\node\node.exe C:\Users\xyz\.vaadin\node\node_modules\npm\bin\npm-cli.js --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install' for frontend package installation
[WARNING] package-lock.json is missing from this project. This may cause the npm package installation to take several minutes. It is recommended to keep the package-lock.json file persistently in your project. Please stand by...
npm WARN ERESOLVE overriding peer dependency
npm WARN ERESOLVE overriding peer dependency
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: rollup-plugin-babel#4.4.0
npm WARN Found: rollup#0.47.6
npm WARN node_modules/.pnpm/validator#13.7.0/node_modules/validator/node_modules/rollup
npm WARN dev rollup#"^0.47.0" from validator#13.7.0
npm WARN node_modules/.pnpm/validator#13.7.0/node_modules/validator
npm WARN validator#13.7.0
npm WARN node_modules/validator
npm WARN validator#13.7.0
npm WARN node_modules/.pnpm/#vaadin/form#0.0.15_lit#2.0.0/node_modules/validator
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer rollup#">=0.60.0 <3" from rollup-plugin-babel#4.4.0
npm WARN node_modules/.pnpm/validator#13.7.0/node_modules/validator/node_modules/rollup-plugin-babel
npm WARN dev rollup-plugin-babel#"^4.0.1" from validator#13.7.0
npm WARN node_modules/.pnpm/validator#13.7.0/node_modules/validator
npm WARN
npm WARN Conflicting peer dependency: rollup#2.70.1
npm WARN node_modules/rollup
npm WARN peer rollup#">=0.60.0 <3" from rollup-plugin-babel#4.4.0
npm WARN node_modules/.pnpm/validator#13.7.0/node_modules/validator/node_modules/rollup-plugin-babel
npm WARN dev rollup-plugin-babel#"^4.0.1" from validator#13.7.0
npm WARN node_modules/.pnpm/validator#13.7.0/node_modules/validator
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: webpack-merge#4.2.2
npm WARN Found: peer eslint-plugin-jsx-a11y#"^3.0.2 || ^4.0.0" from eslint-config-airbnb#14.1.0
npm WARN node_modules/.pnpm/webpack-merge#4.2.2/node_modules/webpack-merge/node_modules/eslint-config-airbnb
npm WARN dev eslint-config-airbnb#"^14.1.0" from webpack-merge#4.2.2
npm WARN node_modules/.pnpm/webpack-merge#4.2.2/node_modules/webpack-merge
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint-plugin-jsx-a11y#"^3.0.2 || ^4.0.0" from eslint-config-airbnb#14.1.0
npm WARN node_modules/.pnpm/webpack-merge#4.2.2/node_modules/webpack-merge/node_modules/eslint-config-airbnb
npm WARN dev eslint-config-airbnb#"^14.1.0" from webpack-merge#4.2.2
npm WARN node_modules/.pnpm/webpack-merge#4.2.2/node_modules/webpack-merge
npm ERR! Cannot read properties of null (reading 'isDescendantOf')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xyz\AppData\Local\npm-cache\_logs\2022-04-02T20_04_31_034Z-debug-0.log
[ERROR] Command `C:\Users\xyz\.vaadin\node\node.exe C:\Users\xyz\.vaadin\node\node_modules\npm\bin\npm-cli.js --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install` failed:
[ERROR] >>> Dependency ERROR. Check that all required dependencies are deployed in npm repositories.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 07:43 min
[INFO] Finished at: 2022-04-02T22:11:51+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:23.0.3:build-frontend (default) on project my-app: Could not execute build-frontend goal: Npm install has exited with non zero status. Some dependencies are not installed. Check npm command output -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Why am I not surprised? This would have been the first time that a Vaadin upgrade worked out of the box... :-(
Never mind - I did a "Vaadin dance" and then the build worked. And the application - at least on first sight - also worked OK again.
Later addition - since I was asked to provide the steps. My "Vaadin dance" looks like so:
#echo off
:package_entries
set fn=package.json
echo Step 1: Going to remove unsupported Vaadin v19+ entries from %fn%:
pause
rem let user see what we do:
#echo on
type %fn% | findstr /V /C:"#vaadin/application-theme-plugin" > %fn%_1
type %fn%_1 | findstr /V /C:"#vaadin/stats-plugin" > %fn%_2
type %fn%_2 | findstr /V /C:"#vaadin/theme-live-reload-plugin" > %fn%_3
type %fn%_3 | findstr /V /C:"#vaadin/theme-loader" > %fn%_4
rem remove an already existing backup - just in case (if there were one the cp below won't work)
rm %fn%~
rem rename back to original and keep a backup:
cp -b -f %fn%_4 %fn%
rem delete the temp. files":
rm %fn%_?
#echo off
echo unsupported Vaadin v19+ entries removed from %fn%.
:local_stuff
echo Step 2: Going to remove project local stuff:
pause
rem let user see what we do:
#echo on
call mvn vaadin:clean-frontend
rmdir /S /Q .\target
rmdir /S /Q .\node_modules
rmdir /S /Q .\frontend\generated
rm package.json
rm package-lock.json
rm pnpm-lock.yaml
rm pnpmfile.js
rm tsconfig.json
rm types.d.ts
rm webpack.config.js
rm webpack.generated.js
#echo off
echo project local vaadin-generated stuff removed.
:global_stuff
echo Step 3: Going to remove global stuff: removing pnpm stuff
pause
rem let user see what we do:
#echo on
rm -r -f %USERPROFILE%\.pnpm-debug.log
rm -r -f %USERPROFILE%\.pnpm-state.json
rmdir /S /Q %USERPROFILE%\.vaadin
rmdir /S /Q %USERPROFILE%\.pnpm-store
rem just in case - I encountered them here, too:
rmdir /S /Q D:\.pnpm-store
rmdir /S /Q U:\.pnpm-store
#echo off
echo global vaadin-installed stuff removed.
rem clear (and preload) default repository:
:repo_stuff
echo Step 4: Going to empty m2repository!
pause
rem let user see what we do:
#echo on
rem strange enough I again and again got "access denied" on certain .jars ||-( So we first take ownership...
takeown /R /F %USERPROFILE%\.m2\m2repository
rem ... before removing the stuff:
rm -r -f %USERPROFILE%\.m2\m2repository\*
cp -R %USERPROFILE%\.m2\repo-preload\* %USERPROFILE%\.m2\m2repository
#echo off
echo m2repository cleaned.
echo.
pause
I do this in multiple steps:
1st run: execute up to first pause - try to rebuild
if still not working:
2nd run: re-execute from top up to second pause - try to rebuild
if still not working:
3rd run: re-execute from top up to third pause - try to rebuild
At the latest after running the entire cmd-file the rebuilds so far always worked...
Deleting the node_modules folder worked for me most of the time.

biber wants to load libcrypt.so.1 but it is missing

I am Arch GNU/Linux user who usually manages almost every package with pacman; I manage TeX and LaTeX-related things with tlmgr. I installed tlmgr from source.
I am writing paper. I would like to use bibliography.
When I tried latexmk -pdflua main.ltx:
Rc files read:
latexmkrc
Latexmk: This is Latexmk, John Collins, 20 November 2021, version: 4.76.
Latexmk: applying rule 'biber main'...
Rule 'biber main': The following rules & subrules became out-of-date:
'biber main'
------------
Run number 1 of rule 'biber main'
------------
------------
Running 'biber "main.bcf"'
------------
biber: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
biber main: Could not open biber log file for 'main'
Latexmk: Use the -f option to force complete processing,
unless error was exceeding maximum runs, or warnings treated as errors.
libcrypt.so* on my environment
$ pacman -Qo /usr/lib/libcrypt*
/usr/lib/libcrypto.so is owned by openssl 1.1.1.m-1
/usr/lib/libcrypto.so.1.1 is owned by openssl 1.1.1.m-1
/usr/lib/libcryptsetup.so is owned by cryptsetup 2.4.3-2
/usr/lib/libcryptsetup.so.12 is owned by cryptsetup 2.4.3-2
/usr/lib/libcryptsetup.so.12.7.0 is owned by cryptsetup 2.4.3-2
/usr/lib/libcrypt.so is owned by libxcrypt 4.4.28-1
/usr/lib/libcrypt.so.2 is owned by libxcrypt 4.4.28-1
/usr/lib/libcrypt.so.2.0.0 is owned by libxcrypt 4.4.28-1
What I tried else
I uninstalled and re-installed biber on tlmgr but did not work.
# ln -s /usr/lib/libcrypt.so /usr/lib/libcrypt.so.1
$ latexmkrc -pdflua main.ltx
Rc files read:
latexmkrc
Latexmk: This is Latexmk, John Collins, 20 November 2021, version: 4.76.
Latexmk: applying rule 'biber main'...
Rule 'biber main': The following rules & subrules became out-of-date:
'biber main'
------------
Run number 1 of rule 'biber main'
------------
------------
Running 'biber "main.bcf"'
------------
/tmp/par-716861/cache-0e6aa298f0c2e7a775de99938825b2d56bd2027f/biber: /usr/lib/libcrypt.so.1: version `GLIBC_2.2.5' not found (required by /tmp/par-716861/cache-0e6aa298f0c2e7a775de99938825b2d56bd2027f/biber)
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
biber main: Could not open biber log file for 'main'
Latexmk: Use the -f option to force complete processing,
unless error was exceeding maximum runs, or warnings treated as errors.
File source
latexmkrc:
$latex='lualatex %O -synctex=1 -interaction=nonstopmode %S';
#$bibtex='upbibtex %O %B';
$bibtex='biber %O %B';
$makeindex='upmendex %O -o %D %S';
$pdf_mode=3;
Install libxcrypt-compat from the Core (1) repository, as suggest in this answer.
This made my biber from TeX Live 2020 work again. The interesting question is if newer TeX distributions will require this package, too.
(1) Thanks to #samueldy for the hint that the package was moved from the AUR to Core.
Adding on to #Christoph90's answer, as of 25 May 2022 the libxcrypt-compat package is still required in TeX Live 2022 in order for biber to function on Manjaro 21.2.6. However, the package has moved to core/libxcrypt-compat, so install by doing
sudo pacman -S libxcrypt-compat

Kernel pid terminated application start failure, bad_return

I wrote a cowboy project that I start on localhost with gmake run.
When I make run on a fresh installation, this error happens:
~/tunnel# make run
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[1]: Entering directory `/root/tunnel/deps/cowboy'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Entering directory `/root/tunnel/deps/cowlib'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Leaving directory `/root/tunnel/deps/cowlib'
make[2]: Entering directory `/root/tunnel/deps/ranch'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Leaving directory `/root/tunnel/deps/ranch'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
GEN rebar.config
make[1]: Leaving directory `/root/tunnel/deps/cowboy'
make[1]: Entering directory `/root/tunnel/deps/jiffy'
./rebar compile
==> jiffy (compile)
make[1]: Leaving directory `/root/tunnel/deps/jiffy'
DEPEND tunnel.d
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
ERLC tunnel_app.erl
APP tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/root/tunnel/ebin
/root/tunnel/deps
/usr/local/lib/erlang/lib
/root/tunnel/apps
/root/tunnel/_rel
===> Resolved tunnel_release-1
===> Including Erts from /usr/local/lib/erlang
===> release successfully created!
===> tarball /root/tunnel/_rel/tunnel_release/tunnel_release-1.tar.gz successfully created!
Exec: /root/tunnel/_rel/tunnel_release/erts-9.0/bin/erlexec -boot /root/tunnel/_rel/tunnel_release/releases/1/tunnel_release -mode embedded -boot_var ERTS_LIB_DIR /root/tunnel/_rel/tunnel_release/erts-9.0/../lib -config /root/tunnel/_rel/tunnel_release/releases/1/sys.config -args_file /root/tunnel/_rel/tunnel_release/releases/1/vm.args -- console
Root: /root/tunnel/_rel/tunnel_release
/root/tunnel/_rel/tunnel_release
heart_beat_kill_pid = 16083
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [kernel-poll:false]
=INFO REPORT==== 29-Sep-2017::11:46:35 ===
application: tunnel
exited: {bad_return,
{{tunnel_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_clear,
[my_http_listener,100,
[{port,8080}],
#{env =>
#{dispatch =>
[{'_',[],
[{[<<"info">>],[],lobby_handler,[]},
{[<<"join">>,name],[],join_handler,[]},
{[<<"player">>,<<"status">>,name],
[],player_status_handler,[]},
{[<<"tables">>,<<"info">>,table_id],
[],table_info_handler,[]},
{[<<"tables">>,<<"play">>,table_id,name,auth,
action,x,y],
[],table_play_handler,[]},
{[<<"assets">>,'...'],
[],cowboy_static,
{dir,"/root/tunnel/static/assets/"}}]}]}}],
[]},
{tunnel_app,start,2,[{file,"src/tunnel_app.erl"},{line,17}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,100,[{port,8080}],#{env => #{dispatch => [{'_',[],[{[<<\"info\">>],[],lobby_handler,[]},{[<<\"join\">>,name],[],join_handler,[]},{[<<\"player\">>,<<\"status\">>,name],[],player_status_handler,[]},{[<<\"tables\">>,<<\"info\">>,table_id],[],table_info_handler,[]},{[<<\"tables\">>,<<\"play\">>,table_id,name,auth,action,x,y],[],table_play_handler,[]},{[<<\"assets\">>,'...'],[],cowboy_static,{dir,\"/root/tunnel/static/assets/\"}}]}]}}],[]},{tunnel_app,start,2,[{file,\"src/tunnel_app.erl\"},{line,17}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,100,[{port,8080}],#{
heart: Fri Sep 29 11:46:36 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Fri Sep 29 11:46:36 2017: Would reboot. Terminating.
make: *** [run] Error 1
I see bad return for the tunnel_app
This is my tunnel_app.erl
-module(tunnel_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/info", lobby_handler, []},
{"/join/:name", join_handler, []},
{"/player/status/:name", player_status_handler, []},
{"/tables/info/:table_id", table_info_handler, []},
{"/tables/play/:table_id/:name/:auth/:action/:x/:y", table_play_handler, []},
{"/assets/[...]", cowboy_static, {dir, "/users/quantum/tunnel/static/assets/"}}
]}]),
{ok, _} = cowboy:start_clear(my_http_listener, 100,
[{port, 8080}],
#{env => #{dispatch => Dispatch}}),
{ok, MainDoor} = door:go(),
register(main_door, MainDoor),
{ok, MainRoom} = room:go(),
register(main_room, MainRoom),
tunnel_sup:start_link().
stop(_State) ->
ok.
and the tunnel_sup.erl that it calls with start_link:
-module(tunnel_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
Procs = [],
{ok, {{one_for_one, 1, 5}, Procs}}.
I checked my .gitignore
.erlang.mk/
*.beam
src/*.beam
_rel/
deps/
ebin/
The full repository is here: https://github.com/quantumproductions/tunnel
I'm able to copy a folder on my machine and it works. When I upload this to github and download it, make run fails.
~/tunnel3/ls
Makefile deps erlang.mk rel src tunnel.d
_rel ebin oldh relx.config static
~/tdep/ls
Makefile deps erlang.mk rel src tunnel.d
_rel ebin oldh relx.config static
the second one fails:
~/tdep/gmake run
Error: No Makefile to build dependency /Users/quantum/tdep/deps/cowboy.
gmake: *** [erlang.mk:4182: deps] Error 2
first folder works fine
/tunnel3/gmake run
gmake[1]: Entering directory '/Users/quantum/tunnel3/deps/cowboy'
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/cowlib'
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/cowlib'
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/ranch'
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/ranch'
GEN rebar.config
gmake[1]: Leaving directory '/Users/quantum/tunnel3/deps/cowboy'
gmake[1]: Entering directory '/Users/quantum/tunnel3/deps/jiffy'
CC=gcc ./enc compile
gmake -f c_src/Makefile.erlang.mk
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/jiffy'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/jiffy'
gmake[1]: Leaving directory '/Users/quantum/tunnel3/deps/jiffy'
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/tunnel3/ebin
/Users/quantum/tunnel3/deps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/tunnel3/apps
/Users/quantum/tunnel3/_rel
What configuration could be causing this?
EDIT:
Juanjo Martin's answer works, in my cloned folder.
In my original folder, it does not, and removing the 100 argument gets me the below.
Why is this not working in 1 specific folder? What kind of environment fix do I have to check/make to prevent this? It seems like ~/tunnel is running a different version of cowboy?
/tunnel/gmake run
gmake[1]: Entering directory '/Users/quantum/tunnel/deps/cowboy'
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/cowlib'
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/cowlib'
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/ranch'
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/ranch'
GEN rebar.config
gmake[1]: Leaving directory '/Users/quantum/tunnel/deps/cowboy'
gmake[1]: Entering directory '/Users/quantum/tunnel/deps/jiffy'
CC=gcc ./enc compile
gmake -f c_src/Makefile.erlang.mk
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/jiffy'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/jiffy'
gmake[1]: Leaving directory '/Users/quantum/tunnel/deps/jiffy'
DEPEND tunnel.d
ERLC tunnel_app.erl
APP tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/tunnel/ebin
/Users/quantum/tunnel/deps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/tunnel/apps
/Users/quantum/tunnel/_rel
===> Resolved tunnel_release-1
===> Including Erts from /usr/local/Cellar/erlang/19.2/lib/erlang
===> release successfully created!
===> tarball /Users/quantum/tunnel/_rel/tunnel_release/tunnel_release-1.tar.gz successfully created!
Exec: /Users/quantum/tunnel/_rel/tunnel_release/erts-8.2/bin/erlexec -boot /Users/quantum/tunnel/_rel/tunnel_release/releases/1/tunnel_release -mode embedded -boot_var ERTS_LIB_DIR /Users/quantum/tunnel/_rel/tunnel_release/erts-8.2/../lib -config /Users/quantum/tunnel/_rel/tunnel_release/releases/1/sys.config -args_file /Users/quantum/tunnel/_rel/tunnel_release/releases/1/vm.args -- console
Root: /Users/quantum/tunnel/_rel/tunnel_release
/Users/quantum/tunnel/_rel/tunnel_release
heart_beat_kill_pid = 3135
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
=INFO REPORT==== 5-Oct-2017::16:54:36 ===
application: tunnel
exited: {bad_return,
{{tunnel_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_clear,
[my_http_listener,
[{port,8080}],
#{env => #{dispatch => [{'_',[],
[{[<<"info">>],[],lobby_handler,[]},
{[<<"join">>,name],
[],join_handler,[]},
{[<<"player">>,<<"status">>,name],
[],player_status_handler,[]},
{[<<"tables">>,<<"info">>,table_id],
[],table_info_handler,[]},
{[<<"tables">>,<<"play">>,table_id,
name,auth,action,x,y],
[],table_play_handler,[]},
{[<<"assets">>,'...'],
[],cowboy_static,
{dir,
"/users/quantum/tunnel/static/assets/"}}]}]}}],
[]},
{tunnel_app,start,2,
[{file,"src/tunnel_app.erl"},{line,17}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,[{port,8080}],#{env => #{dispatch => [{'_',[],[{[<<\"info\">>],[],lobby_handler,[]},{[<<\"join\">>,name],[],join_handler,[]},{[<<\"player\">>,<<\"status\">>,name],[],player_status_handler,[]},{[<<\"tables\">>,<<\"info\">>,table_id],[],table_info_handler,[]},{[<<\"tables\">>,<<\"play\">>,table_id,name,auth,action,x,y],[],table_play_handler,[]},{[<<\"assets\">>,'...'],[],cowboy_static,{dir,\"/users/quantum/tunnel/static/assets/\"}}]}]}}],[]},{tunnel_app,start,2,[{file,\"src/tunnel_app.erl\"},{line,17}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,[{port,8080}],#{env
heart: Thu Oct 5 16:54:37 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Thu Oct 5 16:54:37 2017: Would reboot. Terminating.
gmake: *** [erlang.mk:6450: run] Error 1
~/tunnel/
Aha. I did the comment's instruction from #lastcanal and it works. Thanks.
First thing I see is you don't have an .app file
You can check a similar problem in why-is-my-cowboy-server-not-running
flag
In tunnel_app.erl module you're calling cowboy:start_clear with an arity of 4 but the arity for this function is 3. That's why the undef error:
exited: {bad_return, {{tunnel_app,start,[normal,[]]}, {'EXIT', {undef, [{cowboy,start_clear, [my_http_listener,100, [{port,8080}],
... You should remove the parameter "100"
This must have been from an earlier version of Cowboy, possibly

"escript: no such file or directory:" error

%cat fact
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
try
N = list_to_integer(String),
F = fac(N),
io:format("factorial ~w = ~w\n", [N,F])
catch
_:_ ->
usage()
end;
main(_) ->
usage().
usage() ->
io:format("usage: factorial integer\n"),
halt(1).
fac(0) -> 1;
fac(N) -> N * fac(N-1).
%./fact "5"
escript: no such file or directory: './fact'
%whereis escript
escript: /usr/bin/escript
%pacman -Qi erlang
name   : erlang
version  : R14B04-1
Why doesnot escript run "fact" ?
On my Archlinux box, escript still doesnot work !
%cat hello.erl
main(_) -> io:fwrite("~p~n", "hello,world!").
%escript hello.erl
escript: no such file or directory: 'hello.erl'
%whereis escript
escript: /usr/bin/escript
%ls -l /usr/bin/escript
lrwxrwxrwx 1 root root 25 12月 18 17:37 /usr/bin/escript -> ../lib/erlang/bin/escript*
%/usr/lib/erlang/bin/escript hello.erl
escript: no such file or directory: 'hello.erl'
%strace -f -F -o aaa.txt /usr/lib/erlang/bin/escript hello.erl
escript: no such file or directory: 'hello.erl
%cat aaa.txt
execve("/usr/lib/erlang/bin/escript", ["/usr/lib/erlang/bin/escript", "hello.erl"], [/* 40 vars */]) = 0
...
open("hello.erl", O_RDONLY|O_LARGEFILE) = 3
...
execve("/usr/lib/erlang/bin/erl", ["/usr/lib/erlang/bin/erl", "+B", "-boot", "start_clean", "-noshell", "-run", "escript", "start", "-extra", "hello.erl"], [/* 40 vars */]) = 0.
...
stat64("hello.erl", 0xb5a44d90) = -1 ENOENT (No such file or directory)
open("hello.erl", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
......
Why does it use "stat64" instead of "stat" ? I am using 32 bits system.
%uname -a
Linux myarch 3.1.5-1-ARCH #1 SMP PREEMPT Sun Dec 11 06:26:14 UTC 2011 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux
%erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.8.5
Sincerely!
%ls
fact*
%escript fact "5"
escript: no such file or directory: 'fact'
%escript fact 5
escript: no such file or directory: 'fact
%ls -l /usr/bin/escript
lrwxrwxrwx 1 root root 25 10月 15 03:24 /usr/bin/escript -> ../lib/erlang/bin/escript*
Strange problem ?
** NOTE * This answer is customized for Windows Users, but can be understood and useful to other opertaing system users
Is escript in the $PATH environment variable ? usually its hidden in ERTS_PATH/bin where ERTS_PATH is in C:\Program Files (x86)\erl5.8.4\erts-5.8.4\ in Windows 7. look for the equivalent on Linux or Unix or MAC for erts. add this path (C:\Program Files (x86)\erl5.8.4\erts-5.8.4\bin) to the $PATH. escript should be able to work anywhere
The reason is VERY simple. Because the following line is in ~/.erlang:
file:set_cwd("/media/D/www/qachina/db/doc/erlang")
so that escript will change the current directory once executed. The escript works great after removing that line.
Best Regards!
The same script I copied and it is working.
Make sure after you have written the above script, you are running the script as follows
escript <scriptName> <argument>
eg:- escript fact 5
For detailed information:
http://www.erlang.org/doc/man/escript.html
activate the erlang, lets say erlang is in root:
. /root/erlang/r15b01/activate

Resources