I’m using: SWI-Prolog version: current swipl-devel on MSYS2/MinGW
I want the code to: pass the unit tests
But what I’m getting is: a problem in swipl:core
The output looks like this:
4: ERROR: c:/msys64/home/matthias/swipl-devel/packages/clib/unix.pl:63:
4: ERROR: c:/msys64/home/matthias/swipl-devel/packages/clib/unix.pl:63: Initialization goal raised exception:
4: ERROR: Das angegebene Modul wurde nicht gefunden.
4:
In line 63, unix.pl tries to load foreign(unix) which is not being created during compilation. The thing is: I ran ctest yesterday, and swipl/core passed. So, what I am wondering is: Has unix.dll been there in the past, and for some reason, it is not generated anymore? Or has something else changed? I cannot see obvious changes in the repo.
Good question. I added a test called test_signals.pl yesterday. That however checks for the availability of library(unix) and seems correctly skipped under Windows. I don’t know what made the difference. unix.pl should not exist in home/library on Windows, but does of course exist in the package.
Tests should not (try) to load unix.pl on Windows. Typically one should do that using
:- if(exists_source(library(unix))).
...
Question is what is loading this code? A grep for unix in the core tests only reveals test_answer.pl and test_signals.pl, both seem to have proper conditions. The last resort I normally use is to put this in the module that should be loaded to see where it is loaded from:
:- backtrace(50).
After loading into an interactive session you can also use e.g.
?- source_file_property(library(unix), P).
to enumerate all properties, which includes the load site(s).
?- use_foreign_library(foreign(unix), install_unix).
ERROR: Initialization goal shlib:load_foreign_library(user:foreign(unix),install_unix) raised exception:
ERROR: Das angegebene Modul wurde nicht gefunden.
ERROR: In:
ERROR: [21] throw(error(shared_object(open,'Das angegebene Modul wurde nicht gefunden.\r\n'),context(...,_9166)))
ERROR: [19] <meta call>
ERROR: [18] with_mutex('$foreign',load_foreign_library(foreign(unix),user,install_unix)) <foreign>
ERROR: [16] '$run_init_goal'(shlib:load_foreign_library(...,install_unix)) at c:/msys64/mingw64/boot/init.pl:811
ERROR: [15] catch(system:'$run_init_goal'(...),_9302,system:'$initialization_error'(_9324,...,-)) at c:/msys64/mingw64/boot/init.pl:562
ERROR: [14] catch_with_backtrace(system:'$run_init_goal'(...),_9360,system:'$initialization_error'(_9382,...,-)) at c:/msys64/mingw64/boot/init.pl:629
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
true.
The call returns true although it fails, may this cause trouble (?)
Edit: I appended a “, fail.” to the line, the problem is still there.
The funny thing is that exists_source(library(unix)) returns false for both the “installed” swipl at /mingw64/bin/swipl as well as for the one that is used for ctest, build/src/swipl.exe.
A workaround would be a further condition \+ current_prolog_flag(windows, true), as indicated above. Is this acceptable?
Something seems to do something dubious to the search path Ah, this actually is test_answer.pl! I think the path fiddling at the top there can go and that could also use the exists_source(library(unix)). These are still left-overs from the days before CMake when the build was done in the source directory and we needed all these tricks
I won’t blame you if you ask me to clean this (but of course, I do appreciate PRs)