# Absolute\_file\_name confusion

**URL:** <https://swi-prolog.discourse.group/t/absolute-file-name-confusion/9571>\
**Category:** General\
**Created:** [April 14, 2026, 2:41pm UTC](https://swi-prolog.discourse.group/t/absolute-file-name-confusion/9571 "2026-04-14T14:41:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcculloch](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mcculloch](https://swi-prolog.discourse.group/u/mcculloch)\
**Post date:** [April 14, 2026, 2:41pm UTC](https://swi-prolog.discourse.group/t/absolute-file-name-confusion/9571/1 "2026-04-14T14:41:51Z")

</div>

I’m on version 10.0.2. I have an init.pl file:

```prolog
:- multifile user:file_search_path/2.

user:file_search_path(home,Dir) :-
getenv(‘HOME’,Dir).

user:file_search_path(apps,home(‘Applications’)).

```

When I query for home and apps with file\_search\_path and absolute\_file\_name, the former works as expected but the latter doesn’t. Here’s what I got:

_70 ?- file\_search\_path(home,X).  
X = ‘/home/john’._

_71 ?- file\_search\_path(apps,X).  
X = home(‘Applications’)._

_72 ?- absolute\_file\_name(home,F).  
F = ‘/home/john/home’._

_73 ?- absolute\_file\_name(apps,F).  
F = ‘/home/john/apps’._

Apparently, I don’t understand how absolute\_file\_name works. I don’t remember how to mark text in a post as code so I tried some other things. I wanted the absolute\_file\_name calls to give me ‘/home/john’ and ‘/home/john/Applications’. Where have I gone wrong?

Thanks

---

<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:** [April 14, 2026, 3:14pm UTC](https://swi-prolog.discourse.group/t/absolute-file-name-confusion/9571/2 "2026-04-14T15:14:46Z")

</div>

> [@mcculloch](#):
>
> I wanted the absolute\_file\_name calls to give me ‘/home/john’

Try

```
?- absolute_file_name(home('.'), Home, [file_type(directory)]).

```

To use an alias, you always write Alias(PathBelowAlias) for absolute\_file\_name/3. By default, this predicate only gives files, so you need `file_type(directory)` to make it find a directory.

> [@mcculloch](#):
>
> mark text in a post as code

Inline: use ``code``. For a block, indent by 4 spaces or put ````` lines above and below the block.
