How do I install library(scasp)?

I’ve been playing with s(CASP) inside SWISH, but recently decided to start playing with it in a local installation of swipl on an Ubuntu virtual machine. I installed swipl-devel from source, using the instructions on the website, but if I use

:- use_module(library(scasp)).

in my code, I get

ERROR:    source_sink `library(scasp)' does not exist

I can see that GitHub - JanWielemaker/sCASP: top-down interpreter for ASP programs with constraints has a file, and a prolog directory, but I can’t figure out from the documentation how to use the pack predicates to install it.

Any help would be appreciated.

1 Like

I went through a similar process trying to install s(CASP) as a pack to play with locally, but I figured that Jan hasn’t published it as pack yet since it didn’t appear on I took this to be a sign that s(CASP) is still WIP in SWI-Prolog (as the README suggests).
One solution that seemed to work was cloning the sCASP repository and running swipl from within sCASP/prolog:

$ cd sCASP/prolog
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- [''].

Another option is to build a pack archive and install it locally like so:

$ cd sCASP
$ zip -r prolog
$ swipl -q

?- pack_install('').
false.  % I don't know why I get false, 
        % but the installation works nonetheless.
        % I suspect that it's an unrelated issue as
        % I've seen it with other packs as well
?- ^D
% halt

$ cd ~
$ swipl -q

?- use_module(library(scasp)).
1 Like

If you use the latest version, clone the repo, go down into the repo and run

?- pack_install(.).

Should to the job. In older versions, go to the pack directory (~/.local/share/swi-prolog/pack on POSIX systems) and symlink the sCASP directory there or clone it there.

See corrected process in this post.

1 Like

That made some progress, but it seems to fail on the tests.

?- pack_install(.).
% swipl --no-pce -O -o scasp -c prolog/scasp/
% Warning: /home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/
% Warning:    '/home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/':40:48: Illegal multibyte Sequence
% Warning: /home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/
% Warning:    '/home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/':111:23: Illegal multibyte Sequence
% % Disabled autoloading (loaded 111 files)
% % Disabled autoloading (loaded 8 files)
% % Disabled autoloading (loaded 0 files)
% swipl test/
% Warning: /home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/
% Warning:    '/home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/':40:48: Illegal multibyte Sequence
% Warning: /home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/
% Warning:    '/home/jason/src/swipl-devel/packages/sCASP/prolog/scasp/clp/':111:23: Illegal multibyte Sequence
% ...............................
% Warning: /home/jason/src/swipl-devel/packages/sCASP/test/programs/bec_light.pass:1:
% Warning:    '/home/jason/src/swipl-devel/packages/sCASP/test/programs/bec_light.pass':1:5882: Illegal multibyte Sequence
ERROR: ERROR: /home/jason/src/swipl-devel/packages/sCASP/test/ test_scasp:main /home/jason/src/swipl-devel/packages/sCASP/test/programs/bec_light.pass:1:343: Syntax error: Operator expected
% make: *** [Makefile:10: check] Error 2
ERROR: Process "process(/usr/bin/make,[check])": exit status: 2
ERROR:   [26] throw(error(process_error(...,...),_46576))
ERROR:   [22] build_tools:build_step([test],_46626{bin_dir:'/home/jason/.local/share/swi-prolog/pack/scasp',env:[...|...],link:true,pack:scasp,rebuild:make,src_dir:'/home/jason/.local/share/swi-prolog/pack/scasp',url:'file:///home/jason/src/swipl-devel/packages/sCASP/',version:'0.9.0'},_46626{bin_dir:'/home/jason/.local/share/swi-prolog/pack/scasp',env:[...|...],link:true,pack:scasp,rebuild:make,src_dir:'/home/jason/.local/share/swi-prolog/pack/scasp',url:'file:///home/jason/src/swipl-devel/packages/sCASP/',version:'0.9.0'}) at /usr/local/lib/swipl/library/build/
ERROR:   [21] apply:foldl_([[test],install],build_tools:build_step,_46626{bin_dir:'/home/jason/.local/share/swi-prolog/pack/scasp',env:[...|...],link:true,pack:scasp,rebuild:make,src_dir:'/home/jason/.local/share/swi-prolog/pack/scasp',url:'file:///home/jason/src/swipl-devel/packages/sCASP/',version:'0.9.0'},_46742) at /usr/local/lib/swipl/library/
ERROR:   [16] build_tools:build_steps([[dependencies],...|...],'/home/jason/.local/share/swi-prolog/pack/scasp','<garbage_collected>') at /usr/local/lib/swipl/library/build/
ERROR:   [14] prolog_pack:pack_post_install(scasp,'/home/jason/.local/share/swi-prolog/pack/scasp',[link(true),...|...]) at /usr/local/lib/swipl/library/
ERROR:    [9] toplevel_call('<garbage_collected>') at /usr/local/lib/swipl/boot/
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
   Exception: (22) build_tools:build_step([test], _128{bin_dir:'/home/jason/.local/share/swi-prolog/pack/scasp', env:['PATH'='/usr/local/lib/swipl/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'SWIPL'='/usr/local/lib/swipl/bin/x86_64-linux/swipl', 'SWIPLVERSION'=80502, 'SWIHOME'='/usr/local/lib/swipl', 'SWIARCH'='x86_64-linux', ... = ...|...], link:true, pack:scasp, rebuild:make, src_dir:'/home/jason/.local/share/swi-prolog/pack/scasp', url:'file:///home/jason/src/swipl-devel/packages/sCASP/', version:'0.9.0'}, _36510)

I was a bit too optimistic. The Makefile was not updated to deal with the calls it gets from pack_install/1 and there where some issues with Unicode handling that break the tests (and some more). Updated. If you pull SWI-Prolog to the latest git it will also nicely install scasp, either in the same directory of swipl or in ~/bin if one of these is writeable.

So, to install the system

git clone
cd sCASP
swipl -g "pack_install(.)" -t halt

Which should give you library(scasp), etc. to use the system from Prolog and a scasp executable in the current directory that is optionally linked from your preferred directory in $PATH.