SWI-Prolog / packages-jpl

JPL: The Prolog <-> Java interface
BSD 2-Clause "Simplified" License
54 stars 33 forks source link

SWI having trouble with src/swipl.prc in JPL on Linux? #18

Closed ssardina closed 5 years ago

ssardina commented 5 years ago

You mean just nothing relevant? Could java be a shell script so we are tracing the shell rather than the executable? If you examine the output, look for any ".prc" file it is trying.

"swipl.prc" is a zip file. E.g.:

hppc823 (linux; master) 5_> unzip -t src/swipl.prc 
Archive:  src/swipl.prc
    testing: $prolog/state.qlf        OK
No errors detected in compressed data of src/swipl.prc.

Also src/swipl -xsrc/swipl.prc` should work fine.

Originally posted by @JanWielemaker in https://github.com/SWI-Prolog/packages-jpl/issues/17#issuecomment-428486996

ssardina commented 5 years ago

@JanWielemaker , I am about to succeed and run the tests. The issue seems to be with the src/swipl.prc itself. Even if I do the initialization in CLI I get:


[ssardina@Thinkpad-X1 build]$ swipl -x src/swipl.prc 
FATAL ERROR: at Wed Oct 10 23:14:50 2018
    Could not open resource database "src/swipl.prc": Invalid argument]

Of course I have no idea what this means, but I can do swipl -x with the swipl.prc in the system instal:

[ssardina@Thinkpad-X1 build]$ swipl -x /usr/local/src/swipl-7.6.4/unpacked-srcs/src/swipl.prc
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
ssardina commented 5 years ago

If I do:

export SWIPL_BOOT_FILE=/usr/local/src/swipl-7.6.4/unpacked-srcs/src/swipl.prc

then ctest -V -R jpl:prolog_in_java runs. This suggest the swipl.prc produced is having trouble in my Linux box. I don't know where that file comes from or how it is produced at cmake/make time tough..

Just leave this issue open for now. Will do the tests now that I can run them

JanWielemaker commented 5 years ago

I see. I'm rather surprised anything usable came out of this anyway. The solution is simple:

apt-get install zlib1g-dev

And rebuild. What you are actually doing is running your JPL with your installed SWI-Prolog 7.6.4, which still happens to work. Your local build is broken due to the above dependency. I've push a fix for the main repo to refuse building if the zlib dependency cannot be found.

I think, to upgrade, from the toplevel swipl, do

git pull
cd build
rm CMakeCache.txt
cmake ..
make

In any case, src/swipl should run after that. If that works, ctest probably works as well.

ssardina commented 5 years ago

You are right Jan, while making some slow progress, I would be surprised if anything usable came out of this, too messy it seems.. (granted, I am doing many things kind of blindly, which is not good. Thanks for your help!!)

The file src/swipl.prc is indeed important to be loaded for the tests. I need to make that work or otherwise the test suite is hopeless.

I pull your updated repo, rebuilt (I have zlib1g-dev already).

The error is still there but as you can see I can start the local binary of prolog with the src/swipl.prc:

[ssardina@Thinkpad-X1 build]$ ctest -V -R jpl:prolog_in_java
UpdateCTestConfiguration  from :/home/ssardina/git/soft/prolog/swipl-devel.git/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/ssardina/git/soft/prolog/swipl-devel.git/build/DartConfiguration.tcl
Test project /home/ssardina/git/soft/prolog/swipl-devel.git/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 13
    Start 13: jpl:prolog_in_java

13: Test command: /usr/bin/env "SWI_HOME_DIR=../../home" "TEST_JPL=../../../packages/jpl/test_jpl.pl" "/usr/lib/jvm/java-8-oracle/bin/java" "-Djava.library.path=." "-classpath" "/usr/share/java/junit.jar:src/java/jpl.jar:src/java/jpltest.jar" "junit.textui.TestRunner" "org.jpl7.test.TestJUnit"
13: Test timeout computed to be: 9.99988e+06
13: [FATAL ERROR: at Wed Oct 10 23:31:21 2018
13:     Could not open resource database "/home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc": No such file or directory]
1/1 Test #13: jpl:prolog_in_java ...............***Failed    0.09 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.09 sec

The following tests FAILED:
     13 - jpl:prolog_in_java (Failed)
Errors while running CTest
[ssardina@Thinkpad-X1 build]$ l /home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc
-rw-rw-r-- 1 ssardina ssardina 79K Oct 10 23:21 /home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc
[ssardina@Thinkpad-X1 build]$ unzip -t /home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc
Archive:  /home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc
    testing: $prolog/state.qlf        OK
No errors detected in compressed data of /home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc.
[ssardina@Thinkpad-X1 build]$ echo $SWIPL_BOOT_FILE
/home/ssardina/git/soft/prolog/swipl-devel.git/build/src/swipl.prc
[ssardina@Thinkpad-X1 build]$ env SWI_HOME_DIR=home/ src/swipl  -x src/swipl.prc 
Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.19-185-gfd6f70d4c-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

1 ?-  

% halt
[ssardina@Thinkpad-X1 build]$ 
JanWielemaker commented 5 years ago

Just a though: could it be you have LD_LIBRARY_PATH setup to find libswipl.so from the stable version? The 7.6 and 7.7 versions cannot read each others .prc files as the format changed from something weird proprietary to ZIP. If the strace works you should be able to find which libswipl.so it actually loads (and also which libjpl.so for that matter).

If this explains it, I guess I should unset these variables during the tests.

ssardina commented 5 years ago

mmm good point to check, very sharp. Will try it, but tomorrow Jan. I will report on the other issue on the many tests I fixed.

JanWielemaker commented 5 years ago

Thanks for the persistence!

ssardina commented 5 years ago

In the end it was this variable that I have in my system because otherwise JPL-SWI does not run:

LD_PRELOAD=/usr/lib/libswipl.so

I unset that, and worked. I use this to preload the lib or I get similar errors as reported here. This together with what you said of the 7.6 format not being able to open the new 7.7 version!

Thanks, all done.

JanWielemaker commented 5 years ago

lol :( Thanks for all the work! Probably busy with other things most of the day, so the final review and merge will be tomorrow.

I guess I should put something in cmake that will either clear these variables or at least warn the user they are set and may harm.

ssardina commented 5 years ago

Great, no problem Jan, whenever you get some time.

Because setting up an environment to develop JPL as a whole (I have done it before in isolation just for the Java sources) was not so trivial for me, I have, before I forget, documented all the steps:

https://github.com/ssardina-research/packages-jpl/wiki/Developing-JPL

This is for others as much as for myself, as I may forget later what exactly where the subtleties in the process to compile and run JPL from scratch, and to develop to propose changes.

Good luck with the non-JPL/SWI stuff today! :-)