# File\_search\_path

**URL:** <https://swi-prolog.discourse.group/t/file-search-path/6422>\
**Category:** General\
**Tags:** how-to\
**Created:** [March 31, 2023, 6:35am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422 "2023-03-31T06:35:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![heiheshang](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/heiheshang/32/4419_2.png) [@heiheshang](https://swi-prolog.discourse.group/u/heiheshang)\
**Post date:** [March 31, 2023, 6:35am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/1 "2023-03-31T06:35:23Z")

</div>

I spent a lot of time trying to make file\_search\_path include a path to my library, but I was unsuccessful. In my project, there is a subdirectory called “lib” where I place my code, but I cannot make the use\_module method search there. I am using  
`file_search_path(library, './lib')` and expecting that  
`:- use_module(library(bitrix24_auth))` will find my library there, but I receive the message “source\_sink `library(bitrix24\_auth)’ does not exist.” Where am I making a mistake?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 31, 2023, 7:28am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/2 "2023-03-31T07:28:18Z")

</div>

`file_search_path/2` must be in the module `user`. Surely just `lib` will work too, but so should `./lib`. You can use this to see what locations it tries.

```
?- set_prolog_flag(verbose_file_search, true).

```

---

<div class="post-metadata">

**Author:** ![heiheshang](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/heiheshang/32/4419_2.png) [@heiheshang](https://swi-prolog.discourse.group/u/heiheshang)\
**Post date:** [March 31, 2023, 7:59am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/3 "2023-03-31T07:59:38Z")

</div>

`source_sink `library(bitrix24\_auth)’ does not exist`  
All I get

---

<div class="post-metadata">

**Author:** ![heiheshang](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/heiheshang/32/4419_2.png) [@heiheshang](https://swi-prolog.discourse.group/u/heiheshang)\
**Post date:** [March 31, 2023, 8:26am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/4 "2023-03-31T08:26:20Z")

</div>

looking for anywhere, but not in the catalog of my program

---

<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:** [March 31, 2023, 9:20am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/5 "2023-03-31T09:20:26Z")

</div>

Maybe this will help.

[Using absolute\_file\_name/3 and user:file\_search\_path/2](https://swi-prolog.discourse.group/t/using-absolute-file-name-3-and-user-file-search-path-2/5531)

---

<div class="post-metadata">

**Author:** ![heiheshang](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/heiheshang/32/4419_2.png) [@heiheshang](https://swi-prolog.discourse.group/u/heiheshang)\
**Post date:** [March 31, 2023, 10:19am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/6 "2023-03-31T10:19:57Z")

</div>

My question is that I have not achieved success. I managed to force the code to work at the beginning of my module  
`:- assertz(user:file_search_path (library,'/lib ')).`  
Prior to call  
`:- use_module (bitrix24_AUTH)).`

---

<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:** [March 31, 2023, 10:28am UTC](https://swi-prolog.discourse.group/t/file-search-path/6422/7 "2023-03-31T10:28:44Z")

</div>

> [@heiheshang](#):
>
> My question is that I have not achieved success.

Perhaps you should reverse the problem. Instead of trying to create the code first and hoping it works as expected, create a set of queries to see what is happening and then adjust the queries as needed until the desired goal is reached and use that to create the needed code, e.g.

```prolog
?- absolute_file_name(.,Path).
Path = 'c:/users/groot/documents/prolog'.

?- absolute_file_name(lib,Path).
Path = 'c:/users/groot/documents/prolog/lib'.

?- user:file_search_path(Name,Path).
Name = swi,
Path = 'c:/program files/swipl' ;
Name = library,
Path = app_config(lib) ;
Name = library,
Path = swi(library) ;
Name = library,
Path = swi(library/clp) 
...

```

These are just an example of queries to try, in writing the Wiki article many such queries were created before it made sense.
