# Can't find modules

**URL:** <https://swi-prolog.discourse.group/t/cant-find-modules/3358>\
**Category:** Help!\
**Created:** [December 11, 2020, 12:59am UTC](https://swi-prolog.discourse.group/t/cant-find-modules/3358 "2020-12-11T00:59:30Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [December 11, 2020, 10:37am UTC](https://swi-prolog.discourse.group/t/cant-find-modules/3358/2 "2020-12-11T10:37:59Z")

</div>

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](https://www.swi-prolog.org/pldoc/doc_for?object=shell%3Apwd/0), e.g.

```prolog
?- 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.

```prolog
:- 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

```prolog
:- 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.

```prolog
?- [my_code].

```

1. For more advanced use cases use file\_search\_path/2. This is used often in the SWI-Prolog [source code](https://github.com/SWI-Prolog/swipl-devel). ([search](https://github.com/SWI-Prolog/swipl-devel/search?q=file_search_path))

HTH

* * *

Also see:

[Properties of modules and predicates](https://swi-prolog.discourse.group/t/properties-of-modules-and-predicates/2597)  
[SWI-Prolog has check\_installation/0](https://swi-prolog.discourse.group/t/swi-prolog-has-check-installation-0/2716)  
[Using SWI-Prolog’s modules](http://chiselapp.com/user/ttmrichter/repository/gng/doc/trunk/output/tutorials/swiplmodtut.html)  
[Modules in SWI Prolog](https://sewiki.iai.uni-bonn.de/_media/teaching/lectures/alp/2012/08_-_modules_and_objects.pdf)  
[Dwim and other errors, with very simple facts](https://swi-prolog.discourse.group/t/dwim-and-other-errors-with-very-simple-facts/3001)

---

_[View the full topic](https://swi-prolog.discourse.group/t/cant-find-modules/3358)._
