PREFACE: I’m using: SWI-Prolog version 8.0.3. If this is a problem specific to that version please let me know and I’ll go ahead and upgrade to one of the 8.1.x version.
I am trying to create my own custom initialization file. First I found the file named /usr/lib/swi-prolog/swipl.rc. I then copied it to a file named “swipl-for-linux.ini”. I then made a simple modification to my copy that added a sign-on message so I could know that my initialization file had been executed. Here are the lines I appended to my custom initialization file:
% Write a custom sign-on message so we know this file executed.
:- write("Welcome to PEngines."), nl, !.
initmsg :-
write("Welcome to PEngines."),
!.
I then tried to load SWI-Prolog using the command line option to use my initialization file instead of the default one:
swipl -f ./swipl-for-linux.ini
But this led to the following error at the command line:
ERROR: Prolog initialisation failed:
ERROR: module/2: No permission to redefine module `link_xpce' (Already loaded from /usr/lib/swi-prolog/swipl.rc)
This tells me that the default initialization file is still getting executed. I then tried the site wide flag:
swipl -F ./swipl-for-linux.ini
SWI-Prolog did load this time, but did not show my sign-on message. So I tried running the predicate I defined in my ini file named initmsg as another test, but I got an error indicating it was never defined. I then tried putting some phony names for the “-f” argument and discovered that SWI-Prolog does not complain if you give it a bad file name for the custom initialization file. So my iilusory success with the “-F” flag indicates that it failed to load my initialization file like it did do with the “-f” flag.
How can get SWI-Prolog to ignore the default initialization file and use my initialization file instead?
TYPO ON DOCUMENTATION PAGE:
I have been using the following documentation page for this project:
https://www.swi-prolog.org/FAQ/PlInitialisation.html
I found a typo:
- “explicitely” is misspelled. It should be “explicitly”