3
votes

I am using SWI Prolog for a mathematical logic book and the book provided source code for some of the algorithms in Prolog. The problem is that when I try to load a file, the interpreter just prompt something like:

load_files/2: No permission to load source `**' (Non-module file already loaded into module **; trying to load into io)

I looked into the source code and found that most of the files start with:

:- module(**,[***]).

followed by

user:file_search_path(common,'../common').
:- ensure_loaded(ops).
:- ensure_loaded(def).

and it seems that calling ensure_loaded twice with the same file caused the error, and if some of the predicates in the already loaded file (ops.pl for example) will not be defined in the file that tried to load it for the second time.

I tried changing ensure_loaded to use_module and consult but didn't work.

2
I also meet this problem, I tried replace ensure_loaded with reconsult, but the error is still there.Vimos

2 Answers

1
votes

I solved the problem by moving all the ensure_loaded to one file.

0
votes

I just ran into this problem myself.

?- [test].
Warning: test.pl:1:
        test is not a current module (created)
% test compiled 0.00 sec, 3 clauses
true.

Perform an edit on the file and then reconsult and you'll have the problem:

test:  ?- [test].
ERROR: load_files/2: No permission to load source `test.pl' 
       (Non-module file already loaded into module user; trying to load into test)

Solution: use make/0:

test:  ?- make.
% Updating index for library <snip>/packages/pl-6.2.2/lib/swipl-6.2.2/library/
% test compiled 0.00 sec, 2 clauses
true.

Now your changes are loaded.