# Pack\_install/1 failing

**URL:** <https://swi-prolog.discourse.group/t/pack-install-1-failing/3417>\
**Category:** Tools\
**Created:** [December 24, 2020, 7:37pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417 "2020-12-24T19:37:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Hubbard](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Nicholas\_Hubbard](https://swi-prolog.discourse.group/u/Nicholas_Hubbard)\
**Post date:** [December 24, 2020, 7:37pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/1 "2020-12-24T19:37:23Z")

</div>

I am on a brand new SWI-Prolog install and on a new Linux install.

```prolog
    @?- pack_install(reif).
    % Contacting server at https://www.swi-prolog.org/pack/query ... ok
    Install reif@1.0.0 from GIT at https://github.com/meditans/reif.git Y/n? y
    ERROR: Unknown message: pack(cannot_create_dir(pack('.')))
    false.

```

I am not sure what I am missing. Here is my `check_installation/0`

```prolog
    1 ?- check_installation.
    % Checking your SWI-Prolog kit for common issues ...
    % 
    % Version: ............. 8.3.16
    % Address bits: ........ 64
    % Architecture: ........ x86_64-linux
    % Installed at: ........ /usr/local/lib/swipl
    % Cores: ............... 8
    % 
    % Checking tcmalloc ............................ ok
    % Checking gmp ................................. ok
    % Loading library(archive) ..................... ok
    % Supported filters: bzip2, compress, gzip, grzip, lrzip, lzip, lzma, lzop, none, rpm, uu, xz
    % Supported formats: 7zip, ar, cab, cpio, empty, gnutar, iso9660, lha, mtree, rar, raw, tar, xar, zip
    % Loading library(cgi) ......................... ok
    % Loading library(crypt) ....................... ok
    % Loading library(bdb) ......................... ok
    % Loading library(double_metaphone) ............ ok
    % Loading library(filesex) ..................... ok
    % Loading library(http/http_stream) ............ ok
    % Loading library(http/json) ................... ok
    % Loading library(http/jquery) ................. ok
    % jQuery from /usr/local/lib/swipl/library/http/web/js/jquery-1.11.3.min.js
    % Loading library(isub) ........................ ok
    Warning: library(jpl) .......................... NOT FOUND
    Warning: See http://www.swi-prolog.org/build/issues/jpl.html
    % Loading library(memfile) ..................... ok
    % Loading library(odbc) ........................ ok
    % Loading library(pce) ......................... ok
    % Loading library(pcre) ........................ ok
    % Loading library(pdt_console) ................. ok
    % Loading library(porter_stem) ................. ok
    % Loading library(process) ..................... ok
    % Loading library(protobufs) ................... ok
    Warning: library(editline) ..................... NOT FOUND
    Warning: See http://www.swi-prolog.org/build/issues/editline.html
    % Loading library(readline) ...Thread 1 (main): foreign predicate system:rl_wrap/0 did not clear exception: 
    	error(type_error(bool,readline),context(system:rl_wrap/0,_7452))
    ................................................ ok
    % Loading library(readutil) .................... ok
    % Loading library(rlimit) ...................... ok
    % Loading library(semweb/rdf_db) ............... ok
    % Loading library(semweb/rdf_ntriples) ......... ok
    % Loading library(semweb/turtle) ............... ok
    % Loading library(sgml) ........................ ok
    % Loading library(sha) ......................... ok
    % Loading library(snowball) .................... ok
    % Loading library(socket) ...................... ok
    % Loading library(ssl) ......................... ok
    % Loading library(crypto) ...................... ok
    % Loading library(syslog) ...................... ok
    % Loading library(table) ....................... ok
    % Loading library(time) ........................ ok
    % Loading library(tipc/tipc) ................... ok
    % Loading library(unicode) ..................... ok
    % Loading library(uri) ......................... ok
    % Loading library(uuid) ........................ ok
    % Loading library(zlib) ........................ ok
    % Loading library(yaml) ........................ ok
    Warning: Found 2 issues.
    true.

```

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [December 25, 2020, 2:10am UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/2 "2020-12-25T02:10:39Z")

</div>

Works for me, although I get slightly different check\_installation/0 results. Because you have `tcmalloc` in your version, it seems that you built it yourself and didn’t install from the [PPA](https://www.swi-prolog.org/build/PPA.html).

```prolog
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.16)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- pack_install(reif).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install reif@1.0.0 from GIT at https://github.com/meditans/reif.git Y/n? 
% Cloning into '/home/peter/.local/share/swi-prolog/pack/reif'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "reif.git" was downloaded 37 times
Package: reif
Title: Reified if, reification library
Installed version: 1.0.0
Author: Ulrich Neumerkel <ulrich.neumerkel@tuwien.ac.at>
Maintainer: Carlo Nucera <meditans@gmail.com>
Activate pack "reif" Y/n? 
true.

```

```prolog
?- check_installation.
% Checking your SWI-Prolog kit for common issues ...
% 
% Version: ............. 8.3.16
% Address bits: ........ 64
% Architecture: ........ x86_64-linux
% Installed at: ........ /usr/lib/swi-prolog
% Cores: ............... 4
% 
% Checking tcmalloc ............................ not present
Warning: See http://www.swi-prolog.org/build/issues/tcmalloc.html
% Checking gmp ................................. ok
% Loading library(archive) ..................... ok
% Supported filters: bzip2, compress, gzip, grzip, lrzip, lzip, lzma, lzop, none, rpm, uu, xz
% Supported formats: 7zip, ar, cab, cpio, empty, gnutar, iso9660, lha, mtree, rar, raw, tar, xar, zip
% Loading library(cgi) ......................... ok
% Loading library(crypt) ....................... ok
Warning: library(bdb) .......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/bdb.html
% Loading library(double_metaphone) ............ ok
% Loading library(filesex) ..................... ok
% Loading library(http/http_stream) ............ ok
% Loading library(http/json) ................... ok
% Loading library(http/jquery) ................. ok
% jQuery from /usr/share/javascript/jquery/jquery.min.js
% Loading library(isub) ........................ ok
Warning: library(jpl) .......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/jpl.html
% Loading library(memfile) ..................... ok
Warning: library(odbc) ......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/odbc.html
% Loading library(pce) ......................... ok
% Loading library(pcre) ........................ ok
% Loading library(pdt_console) ................. ok
% Loading library(porter_stem) ................. ok
% Loading library(process) ..................... ok
% Loading library(protobufs) ................... ok
% Loading library(editline) .................... ok
% Loading library(readline) .................... ok
% Loading library(readutil) .................... ok
% Loading library(rlimit) ...................... ok
% Loading library(semweb/rdf_db) ............... ok
% Loading library(semweb/rdf_ntriples) ......... ok
% Loading library(semweb/turtle) ............... ok
% Loading library(sgml) ........................ ok
% Loading library(sha) ......................... ok
% Loading library(snowball) .................... ok
% Loading library(socket) ...................... ok
% Loading library(ssl) ......................... ok
% Loading library(crypto) ...................... ok
% Loading library(syslog) ...................... ok
% Loading library(table) ....................... ok
% Loading library(time) ........................ ok
% Loading library(tipc/tipc) ................... ok
% Loading library(unicode) ..................... ok
% Loading library(uri) ......................... ok
% Loading library(uuid) ........................ ok
% Loading library(zlib) ........................ ok
% Loading library(yaml) ........................ ok
Warning: Config: (command line history) 
Warning: found different directory "/home/peter/.swipl-dir-history"
Warning: new location is "/home/peter/.config/swi-prolog/dir-history"
Warning: Found 5 issues.
true.

```

---

<div class="post-metadata">

**Author:** ![Nicholas\_Hubbard](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Nicholas\_Hubbard](https://swi-prolog.discourse.group/u/Nicholas_Hubbard)\
**Post date:** [December 25, 2020, 3:45am UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/3 "2020-12-25T03:45:30Z")

</div>

> [@peter.ludemann](#):
>
> it seems that you built it yourself

Yes this is correct. I should mention that I built SWI-Prolog roughly the same way (might have installed more or less of the required packages for a full build) just a few weeks ago and was able to pack\_install(reif).

---

<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:** [December 25, 2020, 8:36am UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/4 "2020-12-25T08:36:41Z")

</div>

> [@Nicholas\_Hubbard](#):
>
> ```prolog
> ERROR: Unknown message: pack(cannot_create_dir(pack('.')))
> 
> ```

Somehow it cannot find even a candidate directory for installing the packs. These are installed into the first writable directory produced by `pack(.)`. If no such directory exists it will try to create one. This is done by pack\_create\_install\_dir/2 in library(prolog\_pack).

Having not even candidates (which I think is the case because the message is printed as unknown message while it normally prints the candidates) is quite weird. Did you retract clauses for file\_search\_path/2? Try

```
?- [library(prolog_pack)].
?- gtrace, prolog_pack:pack_create_install_dir(Dir, []).

```

and see why this goes wrong.

---

<div class="post-metadata">

**Author:** ![Nicholas\_Hubbard](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Nicholas\_Hubbard](https://swi-prolog.discourse.group/u/Nicholas_Hubbard)\
**Post date:** [December 25, 2020, 2:25pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/5 "2020-12-25T14:25:22Z")

</div>

> [@jan](#):
>
> Did you retract clauses for [file\_search\_path/2](https://www.swi-prolog.org/pldoc/doc_for?object=file_search_path/2)

I did not.

In doing the gtrace the clause that is failing does seem to be `file_search_path/2`. I do not know how to share a gtrace but here is the regular trace:

```prolog
    1 ?- [library(prolog_pack)].
    true.
    
    2 ?- trace, prolog_pack:pack_create_install_dir(Dir,[]).
       Call: (11) prolog_pack:pack_create_install_dir(_11902, []) ? 
    creep
    ^ Call: (12) findall(_12482=create_dir(_12482), (absolute_file_name(pack('.'), _12482, [solutions(all)]), \+exists_file(_12482), \+exists_directory(_12482), file_directory_name(_12482, _12556), (exists_directory(_12556)->access_file(_12556, write);true)), _12580) ? 
    creep
       Call: (18) absolute_file_name(pack('.'), _12482, [solutions(all)]) ? 
    creep
       Call: (24) file_search_path(pack, _12880) ? 
    creep
       Exit: (24) file_search_path(pack, app_data(pack)) ? 
    creep
       Call: (25) file_search_path(app_data, _13002) ? 
    creep
       Exit: (25) file_search_path(app_data, user_app_data('.')) ? 
    creep
       Call: (26) file_search_path(user_app_data, _13124) ? 
    creep
       Call: (32) exception(undefined_global_variable, '$create_search_directories', _13180) ? 
    creep
       Fail: (32) exception(undefined_global_variable, '$create_search_directories', _13180) ? 
    creep
       Fail: (26) file_search_path(user_app_data, _13124) ? 
    creep
       Redo: (25) file_search_path(app_data, _13002) ? 
    creep
       Exit: (25) file_search_path(app_data, common_app_data('.')) ? 
    creep
       Call: (26) file_search_path(common_app_data, _13440) ? 
    creep
       Call: (31) exception(undefined_global_variable, '$create_search_directories', _13506) ? 
    creep
       Fail: (31) exception(undefined_global_variable, '$create_search_directories', _13506) ? 
    creep
       Call: (31) exception(undefined_global_variable, '$create_search_directories', _13602) ? 
    creep
       Fail: (31) exception(undefined_global_variable, '$create_search_directories', _13602) ? 
    creep
       Fail: (26) file_search_path(common_app_data, _13440) ? 
    creep
       Fail: (18) absolute_file_name(pack('.'), _12482, [solutions(all)]) ? 
    creep
    ^ Exit: (12) findall(_12482=create_dir(_12482), prolog_pack:(absolute_file_name(pack('.'), _12482, [solutions(all)]), \+exists_file(_12482), \+exists_directory(_12482), file_directory_name(_12482, _12556), (exists_directory(_12556)->access_file(_12556, write);true)), []) ? 
    creep
       Call: (12) lists:list_to_set([], _13834) ? 
    creep
       Call: (13) pairs:pairs_keys([], _13834) ? 
    creep
       Exit: (13) pairs:pairs_keys([], []) ? 
    creep
       Exit: (12) lists:list_to_set([], []) ? 
    creep
       Call: (12) prolog_pack:pack_create_install_dir([], _11902, []) ? 
    creep
       Call: (13) []=[_18604=_18606|_18600] ? 
    creep
       Fail: (13) []=[_18604=_18606|_18600] ? 
    creep
       Redo: (12) prolog_pack:pack_create_install_dir([], _11902, []) ? 
    creep
       Call: (13) print_message(error, pack(cannot_create_dir(pack('.')))) ? 
    creep
       Call: (18) push_msg(pack(cannot_create_dir(pack('.')))) ? 
    creep
       Call: (21) exception(undefined_global_variable, '$inprint_message', _18880) ? 
    creep
       Fail: (21) exception(undefined_global_variable, '$inprint_message', _18880) ? 
    creep
       Exit: (18) push_msg(pack(cannot_create_dir(pack('.')))) ? 
    creep
       Call: (19) prolog:message(pack(cannot_create_dir(pack('.'))), _18984, _18986) ? 
    creep
       Call: (20) prolog_pack:message(cannot_create_dir(pack('.')), _18984, _18986) ? 
    creep
    ^ Call: (21) setof(_18988, absolute_file_name(pack('.'), _18988, [solutions(all)]), _19008) ? 
    creep
       Call: (33) file_search_path(pack, _19234) ? 
    creep
       Exit: (33) file_search_path(pack, app_data(pack)) ? 
    creep
       Call: (34) file_search_path(app_data, _19264) ? 
    creep
       Exit: (34) file_search_path(app_data, user_app_data('.')) ? 
    creep
       Call: (35) file_search_path(user_app_data, _19294) ? 
    creep
       Call: (41) exception(undefined_global_variable, '$create_search_directories', _19304) ? 
    creep
       Fail: (41) exception(undefined_global_variable, '$create_search_directories', _19304) ? 
    creep
       Fail: (35) file_search_path(user_app_data, _19294) ? 
    creep
       Redo: (34) file_search_path(app_data, _19264) ? 
    creep
       Exit: (34) file_search_path(app_data, common_app_data('.')) ? 
    creep
       Call: (35) file_search_path(common_app_data, _19294) ? 
    creep
       Call: (40) exception(undefined_global_variable, '$create_search_directories', _19314) ? 
    creep
       Fail: (40) exception(undefined_global_variable, '$create_search_directories', _19314) ? 
    creep
       Call: (40) exception(undefined_global_variable, '$create_search_directories', _19314) ? 
    creep
       Fail: (40) exception(undefined_global_variable, '$create_search_directories', _19314) ? 
    creep
       Fail: (35) file_search_path(common_app_data, _19294) ? 
    creep
    ^ Fail: (21) setof(_18988, prolog_pack:absolute_file_name(pack('.'), _18988, [solutions(all)]), _19008) ? 
    creep
       Fail: (20) prolog_pack:message(cannot_create_dir(pack('.')), _18984, _18986) ? 
    creep
       Fail: (19) prolog:message(pack(cannot_create_dir(pack('.'))), _18984, _18986) ? 
    creep
       Call: (19) message_property(error, stream(_19006)) ? 
    creep
       Fail: (19) message_property(error, stream(_19006)) ? 
    creep
       Call: (20) message_property(error, prefix(_19014)) ? 
    creep
       Fail: (20) message_property(error, prefix(_19014)) ? 
    creep
       Call: (24) prolog:message_prefix_hook(thread, _19026) ? 
    creep
       Fail: (24) prolog:message_prefix_hook(thread, _19026) ? 
    creep
    ERROR: Unknown message: pack(cannot_create_dir(pack('.')))
       Call: (17) pop_msg ? 
    creep
       Exit: (17) pop_msg ? 
    creep
       Exit: (13) print_message(error, pack(cannot_create_dir(pack('.')))) ? 
    creep
       Call: (13) fail ? 
    creep
       Fail: (13) fail ? 
    creep
       Fail: (12) prolog_pack:pack_create_install_dir([], _11902, []) ? 
    creep
       Fail: (11) prolog_pack:pack_create_install_dir(_11902, []) ? 
    creep
    false.

```

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [December 25, 2020, 7:37pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/6 "2020-12-25T19:37:11Z")

</div>

What do you get for this?

```prolog
?- forall(absolute_file_name(pack(x), Z, [solutions(all)]), writeln(Z)).
/home/peter/.local/share/swi-prolog/pack/x
/usr/local/share/swi-prolog/pack/x
/usr/share/swi-prolog/pack/x

```

```prolog
?- forall(absolute_file_name(pack(.), Z, [solutions(all)]), writeln(Z)).
/usr/local/share/swi-prolog/pack
/usr/share/swi-prolog/pack

```

~~@jan - I’m curious why I get different results for `pack(x)` and `pack(.)`.~~  
The different results are because `.` is a directory (actually, the current directory) but `x` is (presumably) a file.

---

<div class="post-metadata">

**Author:** ![Nicholas\_Hubbard](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Nicholas\_Hubbard](https://swi-prolog.discourse.group/u/Nicholas_Hubbard)\
**Post date:** [December 25, 2020, 8:16pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/7 "2020-12-25T20:16:01Z")

</div>

> [@peter.ludemann](#):
>
> What do you get for this?

```prolog
    ?- forall(absolute_file_name(pack(x), Z, [solutions(all)]), writeln(Z)).
    true.

```

```prolog
    ?- forall(absolute_file_name(pack(.), Z, [solutions(all)]), writeln(Z)).
    true.

```

---

<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:** [December 26, 2020, 4:18pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/8 "2020-12-26T16:18:56Z")

</div>

Should be fixed now. The patch 55d5ca7786b417e5dff5a763dff29a13dcfbcfac, trying to avoid the creation of config directories was wrong.

For version 8.3.16, this should fix the problem

```
mkdir ~/.local/share/swi-prolog
```

---

<div class="post-metadata">

**Author:** ![Nicholas\_Hubbard](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Nicholas\_Hubbard](https://swi-prolog.discourse.group/u/Nicholas_Hubbard)\
**Post date:** [December 26, 2020, 6:20pm UTC](https://swi-prolog.discourse.group/t/pack-install-1-failing/3417/9 "2020-12-26T18:20:54Z")

</div>

> [@jan](#):
>
> For version 8.3.16, this should fix the problem

This worked thanks for the help.
