Exists_pack/1 should it be created? Is there an equivelent?

Using conditional compilation and loading packages.

Note: There are packs and packages but the name pack is more commonly used for packages; one has to read the word in context to understand the meaning.

When using conditional compilation with source code there is exists_source/1.

Was thinking there should be exists_pack/1 but it does not exist.

Should exists_pack/1 be created? e.g. look for pack.pl .

If not is there an equivalent that should be used?


EDIT

Possible equivelement:

?- exists_source(pack(rocksdb/pack)).
true.

but then to load the pack the spec uses library instead of pack which seems odd.

?- use_module(library(rocksdb)).
true.

Personal notes
exists_source(Source) :-
    exists_source(Source, _Path).

exists_source(Source, Path) :-
    absolute_file_name(Source, Path,
                       [ file_type(prolog),
                         access(read),
                         file_errors(fail)
                       ]).

(ref)

On Ubuntu on WSL 2 on Windows 10

?- user:file_search_path(library,P).
P = app_config(lib) ;
P = swi(library) ;
P = swi(library/clp) ;
P = '/home/groot/.local/share/swi-prolog/pack/wordnet/prolog' ;
P = '/home/groot/.local/share/swi-prolog/pack/rocksdb/prolog' ;
P = pce('prolog/lib').

?- user:file_search_path(pack,P).
P = app_data(pack).

?- absolute_file_name(app_config(.),P).
P = '/home/groot/.config/swi-prolog'.

?- absolute_file_name(swi(.),P).
P = '/usr/lib/swi-prolog'.

?- absolute_file_name(pce(.),P).
P = '/usr/lib/swi-prolog/xpce'.

?- user:file_search_path(pack,P).
P = app_data(pack).

?- user:file_search_path(app_data,P).
P = user_app_data('.') ;
P = common_app_data('.').

?- user:file_search_path(user_app_data,P).
P = '/home/groot/.local/share/swi-prolog'.

?- user:file_search_path(common_app_data,P).
false.

On Windows 10

?- user:file_search_path(library,P).
P = app_config(lib) ;
P = swi(library) ;
P = swi(library/clp) ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/automake/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/bio_analytics/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/bio_db/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/bio_db_repo/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/body_reordering/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/callgraph/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/chess_db/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/clitable/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/cli_table/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/dcg4pt/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/dcgutils/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/debug_call/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/delay/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/dictoo/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/djson/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/dpath/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/edcg/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/fileutils/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/fnotation/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/func/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/function_expansion/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/genutils/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/graphql/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/gvar_syntax/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/gvterm/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/instant_prolog_docs/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/interpolate/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/lambda/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/lib/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/list_util/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/logicmoo_utils/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/markdown/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/mathml/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/matrix/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/mtx/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/multimodal_dcg/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/options/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/os_lib/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/pack_errors/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/pfc/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/pljulia/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/pl_omdb/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/predicate_streams/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prologmud/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_graphviz/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_imagemagick/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_library_collection/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_rdf/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_uriparser/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/prosqlite/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/pubmed/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/quickcheck/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/rdet/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/rdfs2pl/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/real/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/refactor/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/regex/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/reif/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/resp/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/slack_prolog/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/sldnfdraw/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/sparqlprog/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/stoics_lib/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/swipe/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/switex/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/tap/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/typedef/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/uri_qq/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/wgraph/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/xlibrary/prolog' ;
P = 'c:/users/groot/appdata/local/swi-prolog/pack/xtools/prolog' ;
P = pce('prolog/lib').

?- user:file_search_path(pack,P).
P = app_data(pack).

?- user:file_search_path(app_config,P).
P = user_app_config('.') ;
P = common_app_config('.').

?- user:file_search_path(user_app_config,P).
P = 'C:/Users/Groot/AppData/Roaming/swi-prolog'.

?- user:file_search_path(common_app_config,P).
P = 'C:/ProgramData/swi-prolog'.

?- user:file_search_path(swi,P).
P = 'c:/program files/swipl' ;
false.

?- user:file_search_path(swi,P).
P = 'c:/program files/swipl' ;
false.

?- user:file_search_path(app_data,P).
P = user_app_data('.') ;
P = common_app_data('.').

?- user:file_search_path(common_app_config,P).
P = 'C:/ProgramData/swi-prolog'.

?- user:file_search_path(pce,P).
P = 'c:/program files/swipl/xpce'.

For a pack like RocksDB that can be downloaded then needs to be built (make) on Windows this currently can not be built because the build instructions are not enhanced for a Windows build. So while checking for Prolog source code works

:- if(exists_source(pack('rocks-predicates/rocks_preds'))).

use_module/1,2 will fail.

:- use_module(pack('rocks-predicates/rocks_preds')).
ERROR: c:/users/groot/appdata/local/swi-prolog/pack/rocksdb/prolog/rocksdb.pl:54:
ERROR:    c:/users/groot/appdata/local/swi-prolog/pack/rocksdb/prolog/rocksdb.pl:54: Initialization goal raised exception:
ERROR:    The specified module could not be found.

ERROR:    In:
ERROR:     [106] throw(error(shared_object(open,'The specified module could not be found.\r\n'),context(...,_14392)))
ERROR:     [104] <meta call>
ERROR:     [103] with_mutex('$foreign',load_foreign_library(foreign(rocksdb4pl),rocksdb,default(install))) <foreign>
ERROR:     [100] '$run_init_goal'(shlib:load_foreign_library(...)) at c:/program files/swipl/boot/init.pl:811
ERROR:      [99] catch(system:'$run_init_goal'(...),_14530,system:'$initialization_error'(_14552,...,...)) at c:/program files/swipl/boot/init.pl:562
ERROR:      [98] catch_with_backtrace(system:'$run_init_goal'(...),_14588,system:'$initialization_error'(_14610,...,...)) at c:/program files/swipl/boot/init.pl:629

What’s wrong with ?-exists_source(library(rocksdb))? The “packs” are mapped into the library namespace using absolute_file_name/3 and file_search_path/2.

exists_source(library(<Pack name>)) does not always work, e.g.

?- exists_source(library(body_reordering)).
false.

?- exists_source(library(dcgutils)).
false.

?- exists_source(library(genutils)).
false.

?- exists_source(library(logimoo_utils)).
false.

?- exists_source(library(markdown)).
false.

?- exists_source(library(pljulia)).
false.

?- exists_source(library(prolog_graphviz)).
false.

?- exists_source(library(prolog_imagemagick)).
false.

This does:

?- exists_source(pack(body_reordering/pack)).
true.

?- exists_source(pack(dcgutils/pack)).
true.

?- exists_source(pack(genutils/pack)).
true.

?- exists_source(pack(logicmoo_utils/pack)).
true.

?- exists_source(pack(markdown/pack)).
true.

?- exists_source(pack(pljulia/pack)).
true.

?- exists_source(pack(prolog_graphviz/pack)).
true.

?- exists_source(pack(prolog_imagemagick/pack)).
true.

EDIT

As suggested by Jan W. using pack_property/2.

?- pack_property(boody_reordering,directory(Dir)).
false.

?- pack_property(dcgutils,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/dcgutils'.

?- pack_property(genutils,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/genutils'.

?- pack_property(logicmoo_utils,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/logicmoo_utils'.

?- pack_property(markdown,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/markdown'.

?- pack_property(pljulia,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/pljulia'.

?- pack_property(prolog_graphviz,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_graphviz'.

?- pack_property(prolog_imagemagick,directory(Dir)).
Dir = 'c:/users/groot/appdata/local/swi-prolog/pack/prolog_imagemagick'.

% On Ubuntu on WSL 2 on Windows 10
?- pack_property(rocksdb,directory(Dir)).
Dir = '/home/groot/.local/share/swi-prolog/pack/rocksdb'.

Other examples.

?- exists_source(library(rocksdb)).
true.

?- exists_source(library(automake)).
true.

?- exists_source(library(bio_analytics)).
true.

?- exists_source(library(bio_db)).
true.

?- exists_source(library(bio_db_repo)).
true.
?- exists_source(library(silly)).
false.

?- exists_source(pack(silly/pack)).
false.

?- pack_property(silly,directory(Dir)).
false.

In addition, there is pack_property/2