Closed hlieberman closed 7 years ago
@tsloughter I found a way to address this, by running a quick eval which takes in the full .rel file, and generates a list of paths to the libraries for the current release, and appending them to the code path with -pa
. This way console_clean
loads with access to all code specific to the current release version, but with only kernel
and stdlib
loaded/started. Looks like this:
_get_code_paths() {
erl -noshell -boot start_clean -eval "{ok, [{release,_,_,Apps}]} = file:consult(\"$REL_DIR/$REL_NAME.rel\"),lists:foreach(fun(A) -> io:fwrite(\"-pa $ROOTDIR/lib/~p-~s/ebin \", [element(1, A), element(2, A)]) end, Apps),halt()."
}
Then in the handler for console|console_clean|console_boot
:
__code_paths=$(_get_code_paths)
set -- "$BINDIR/erlexec" \
...snip..
${__code_paths} \
...snip..
Did some testing and it looks good. Want me to open a PR?
On August 13, 2016 10:43:20 PM EDT, Paul Schoenfelder notifications@github.com wrote:
@tsloughter I found a way to address this, by running a quick eval which takes in the full .rel file, and generates a list of paths to the libraries for the current release, and appending them to the code path with
-pa
. This wayconsole_clean
loads with access to all code specific to the current release version, but with onlykernel
andstdlib
loaded/started. Looks like this:_get_code_paths() { erl -noshell -boot start_clean -eval "{ok, [{release,_,_,Apps}]} = file:consult(\"$REL_DIR/$REL_NAME.rel\"),lists:foreach(fun(A) -> io:fwrite(\"-pa $ROOTDIR/lib/~p-~s/ebin \", [element(1, A), element(2, A)]) end, Apps),halt()." }
Then in the handler for
console|console_clean|console_boot
:__code_paths=$(_get_code_paths) set -- "$BINDIR/erlexec" \ ...snip.. ${__code_paths} \ ...snip..
Did some testing and it looks good. Want me to open a PR?
Harlan Lieberman-Berg ~hlieberman
Without looking through the commits I can't say for sure, but I would guess that previously a wildcard path was being added for the lib directory, but that has a problem in that it picks up all .beams in the lib directory, not just those for a specific version of a release. Not a problem if you aren't doing hot upgrades/downgrades, but still broken, and likely was removed later for that reason. The behavior today is not technically broken though: the systools script only adds code paths for applications which are specified to systools when generating the script, and since console_clean
only loads kernel
and stdlib
, only the code paths for those two applications get added. It's obviously not very useful for debugging, which is the whole point of console_clean
, since you have to then manually add code paths for applications you want to load, and this is what my proposed change addresses.
Can't we just have the start script set ERL_LIBS
to $RELEASE_ROOT_DIR/lib
before running erl
?
@hlieberman could you please try out #531 to see if it fixes this issue?
closing, please re-open if issue still persists
Running a project with console_clean doesn't properly setup the directories such that you can load modules. For example, a minimal project with only a single direct dependency, say, on jiffy and an extended start script:
You get the following executions:
console:
console_clean: