Absolute_file_name confusion

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

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

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.

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