When I first read it I thought it all looked correct but the fact that you gave just the right amount of detail I tried to reproduce your problem and upon doing so immediately identified your problem and how to solve it.
You are working in a directory, for this example I will
Now in that directory you create a file
Then you start up SWI-Prolog
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.8)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
use chdir/1 to change the directory within the top level.
and to verify the directory is correct I will add a step to check it
then you loaded the facts using
and received an error
ERROR: source_sink `facts' does not exist
ERROR:  throw(error(existence_error(source_sink,facts),_26960))
ERROR:  '$resolve_source_path'(facts,_26992,[expand(false),...]) at c:/program files/swipl/boot/init.pl:2313
ERROR:  '$load_file'(facts,user,[expand(false),...]) at c:/program files/swipl/boot/init.pl:2287
ERROR:  toplevel_call(user:user: ...) at c:/program files/swipl/boot/toplevel.pl:1113
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
which is not the same as the one you received.
However if instead the consult is done as
test is the name of file (
test.pl) without the filetype then
Valuable = gold.
it works as expected.
While the use of chdir/1 will work, in Prolog the customary way to change the working directory is to use working_directory/2, e.g.