Can't find modules

I’m using: SWI-Prolog version 8.3.8

I want the code to: Recognize the modules it has been using for months. I accidentally moved my program files to a different directory (I intended to copy them there). I moved them back, and everything looked fine, until I tried to run them.

But what I’m getting is:
ERROR: c:/users/ed/documents/prolog/rnafold.pl:18:
ERROR: source_sink `setup’ does not exist
Warning: c:/users/ed/documents/prolog/rnafold.pl:18:
Warning: Goal (directive) failed: user:use_module(setup)
My code looks like this:

in the main program:
:- use_module(utilities).
:- use_module(setup).
:- use_module(library(thread)).
:- use_module(parallel).
and, in setup.pl:
:- module(setup, [rules/2, plb/3, base/1, base_e/1, bond_pair/3, nobond/3, init/3, pairs_mn_mx/5, scopes/1]).

As I don’t have the time to write up an entire Wiki article on this, a few things you should consider.

  1. What is the present working directory. Use the predicate pwd/0, e.g.
?- pwd.
% c:/users/groot/documents/prolog/
true.
  1. Ensure that the code in modules such as use_module(utilities). has a file named utilities.pl in the present working directory.

  2. You can change the working directory in code using working_directory/2 with a directive, e.g.

:- working_directory(_,'C:/Users/Groot/Documents/Projects/SWI-Prolog/my_code').
  1. If you are like me and switch between different operating systems then consider
:- if(current_prolog_flag(windows,true)).
:- working_directory(_,'C:/Users/Groot/Documents/Projects/SWI-Prolog/my_code').
:- elif(current_prolog_flag(unix,true)).
:- working_directory(_,'/mnt/c/Users/Groot/Documents/Projects/SWI-Prolog/my_code').
:- endif.
  1. A quick way to check if a file can be loaded is to try to load it manually using consult/1 or with the preferred syntactic sugar of [<file name>], e.g.
?- [my_code].
  1. For more advanced use cases use file_search_path/2. This is used often in the SWI-Prolog source code. (search)

HTH


Also see:

Properties of modules and predicates
SWI-Prolog has check_installation/0
Using SWI-Prolog’s modules
Modules in SWI Prolog
Dwim and other errors, with very simple facts

Thanks for the reply. Unfortunately, changing the working directory doesn’t seem to help.

% c:/Users/Ed/Documents/Eternadev/Setup .pl compiled into setup 0.00 sec, 0 clauses
|    pwd.
% c:/users/ed/documents/eternadev/
true.

?- 
ERROR: c:/users/ed/documents/eternadev/rnafold.pl:18:
ERROR:    source_sink `setup' does not exist
Warning: c:/users/ed/documents/eternadev/rnafold.pl:18:
Warning:    Goal (directive) failed: user:use_module(setup)
% c:/Users/Ed/Documents/Eternadev/Rnafold.pl compiled 0.00 sec, 0 clauses```

So, I compiled setup.pl:     OK
checked with pwd:             OK
compiled rnafold.pl:           Error, setup does not exist!

Here are the beginnings of the two files in question:

:- module(setup, [rules/2, plb/3, base/1, base_e/1, bond_pair/3, nobond/3, init/3, pairs_mn_mx/5, scopes/1]).```

and

/*
RNAFold.pl
Ed Solem
5/24/2020
*/

/***************************************  Working Directory  *******************/

:- working_directory(_,'c:/Users/Ed/Documents/Eternadev').

/************************************************** dynamic predicates ************/

:- dynamic gu_reject/0.
%:- dynamic result/1.


:- dynamic show_bonds/0.
:- assert(show_bonds).

/***********************************************  Modules  ***********************/
:- use_module(utilities).
:- use_module(setup).
:- use_module(library(thread)).
:- use_module(parallel).
  1. Why is there a space before the period?
  2. I think the Setup and setup will be seen as two different files. Did not check.

Bingo!
Don’t know how that space got into the file name.
Thanks lots.