Issues with UNC path

Hi Jan,

I am trying to upgrade my project from swi prolog version 5.6.48 to version 9.2.9-1 but came across some issues with UNC paths.

First issue appeared when I was trying to load a dll from a UNC path


The corresponding trace

When I dont use UNC paths I can start the programm without any problems.

Second I realized that changing the working directory to a UNC path is not working anymore, which might be related to the first issue:

Does anyone know the latest version where working_directory does support UNC paths?

Cheers,
Niclas

Can you try the current development version (9.3.24)? Running Windows (11, home) inside Fedora 42 VirtualBox, I can do

6 ?- open_shared_object('//vboxsvr/swipl-devel/build.win64/src/table.dll', L).
L = 1.

This looks fine to me. I assume you verified that the UNC path actually works as expected using Microsoft tools? I first got it wrong …

When I use
open_shared_object(‘//ad001.siemens.net/dfs001/File/DE/MT_DocMan/MT_DocMan/SWI_V9_zip/w32n.dll’, L).
It does not throw an exception in 9.2.9.
But using “load_foreign_library/3”
open_shared_object throws the exception in the first screenshot, although Path = ‘//ad001.siemens.net/dfs001/File/DE/MT_DocMan/MT_DocMan/SWI_V9_zip/w32n.dll’ just as above.

I tried running the 9.3.24 version, but wasn’t successfull so far

Hmm. Using this file

unc.pl
base('//vboxsvr/swipl-devel/build.win64').
dll('//vboxsvr/swipl-devel/build.win64/src/table.dll').

so(X) :-
    dll(DLL),
    open_shared_object(DLL, X).

ll :-
    dll(DLL),
    load_foreign_library(DLL).

d :-
    base(Dir),
    working_directory(Old, Dir),
    writeln(Old),
    pwd,
    ls.

?- so(X). works. After restarting, ?- ll. works and seems to have done its job:

 ?- current_foreign_library(L, P).
...
L = '//vboxsvr/swipl-devel/build.win64/src/table.dll',
P = [user:new_order_table(_, _), user:order_table_mapping(_, _, _), user:compare_strings(_, _, _, _), user:prefix_string(_, _, _), user:prefix_string(_, _, _, _), user:sub_string(_, _, _), user:table_version(_, _), user:new_table(..., ..., ..., ...), ... : ...|...].

But, changing directory indeed fails:

?- d.
ERROR: directory `'//vboxsvr/swipl-devel/build.win64'' does not exist
ERROR: In:
ERROR:   [14] '$chdir'('//vboxsvr/swipl-devel/build.win64')
ERROR:   [12] d at c:/users/jan/onedrive/documents/prolog/unc.pl:14

Now. Windows terminal cannot cd to a UNC path either :slight_smile:

First target seems to be loading DLLs. What is the difference what you are doing from what I do?

P.s. Please copy/paste text rather than images. I can copy/paste that and search engines can find it, helping others.

First: Thank you for trying to help me! I appreciate it alot.

So: The difference that I could think of is where the program is executed.
It is not possible to set the current working directory to a UNC path, but if I execute the program using a link (icon) where I specify the execution location as a UNC path the current working directory is actually the UNC path I specified.

Now I tried to get the absolute filename of my dll-file but this also leads to an exception:

Call: (13) working_directory(_784,_784) ? skip
Exit: (13) working_directory(//ad001.siemens.net/dfs001/file/de/mt_docman/mt_docman/swi_v9_zip/,//ad001.siemens.net/dfs001/file/de/mt_docman/mt_docman/swi_v9_zip/) ? creep
Call: (13) absolute_file_name(w32n.dll,_4016,[access(read)]) ? skip
Exception: (13) absolute_file_name(w32n.dll,_4016,[access(read)]) ? creep
Call: (16) push_msg(initialization_error(w32:init_,error(existence_error(source_sink,w32n.dll)

While the file does indead exist.
When I start the program specifying the execution location with a local path, that corresponds to the UNC path on my machine, the problem does not occur:

Call: (13) working_directory(_784,_784) ? skip
Exit: (13) working_directory(p:/mt_docman/swi_v9_zip/,p:/mt_docman/swi_v9_zip/) ? creep
Call: (13) absolute_file_name(w32n.dll,_4016,[access(read)]) ? skip
Exit: (13) absolute_file_name(w32n.dll,p:/mt_docman/swi_v9_zip/w32n.dll,[access(read)]) ? creep
Call: (13) load_foreign_library(p:/mt_docman/swi_v9_zip/w32n.dll,[install(w32_install)]) ? skip
Exit: (13) load_foreign_library(w32:p:/mt_docman/swi_v9_zip/w32n.dll,[install(w32_install)]) ? creep

Ah. This is getting somewhere. If I make a copy of the desktop icon can change the working directory of the shortcut to \\vboxsvr\swipl-devel\build.win64\src I can indeed start Prolog, but it is of little use as it can no longer load its foreign libraries. Also

1 ?- ls.
Warning: "." does not exist
false.

2 ?- pwd.
% //vboxsvr/swipl-devel/build.win64/src/
true.

Now I need some courage to dig into the Windows code :frowning: