After updating to the latest daily build for windows I get an error when I load a module using an explicit path, like “lib/module.pl” but not when I use a user-set file search path like “lib(‘module.pl’)”. At the same time, ls/1
can find the file with both paths.
Here’s what the whole setup looks like on disk:
.
│ config.pl
│ load.pl
│
├───lib
│ target_module.pl
│
└───src
module_path.pl
Here’s what the error looks like. Below, the module_path.pl
module is trying to load the lib/target_module.pl
module, taking its path from a predicate in the config.pl
module. It first calls ls/1
with the same path:
% lib/target_module.pl
ERROR: c:/module_paths/src/module_path.pl:5:
ERROR: source_sink `lib/'target_module.pl'' does not exist
Warning: c:/module_paths/src/module_path.pl:5:
Warning: Goal (directive) failed: module_path:(config:target_path(_14496),ls(_14496),use_module(_14496))
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.8-27-g80f956be2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
Note that the first line is output from ls/1
and it can see the target path.
I think use_module/1
raises an error because there is no lib/target_module.pl
path under the same directory as module_path.pl
- but then why does ls/1
not raise a similar error?
The example is a little convoluted- there may be an easier way to show the same errors.
Here are the file contents:
% load.pl
:-prolog_load_context(directory, Dir)
,asserta(user:file_search_path(project_root, Dir)).
user:file_search_path(src, project_root(src)).
user:file_search_path(lib, project_root(lib)).
:-use_module(src(module_path)).
% config.pl
:-module(config, [target_path/1]).
% Raises error
target_path(lib/'target_module.pl').
% Doesn't raise error.
%target_path(lib('target_module.pl')).
% Gives wearning.
%target_path(lib/target_module).
% src/module_path.pl
:-module(module_path,[]).
:-use_module(project_root(config)).
:-config:target_path(P)
,ls(P)
,use_module(P).
% lib/target_module.pl
:-module(target_module, [pred/1
]).
pred(1).
What is the best way to upload this example? Should I send an archive to bugs@swi-prolog.org ?