There is a real show stopper in our application with v8.4.2.
Specifically, it is this artificial limitation of the path length of around 259:
?- absolute_file_name('1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',A).
ERROR: Cannot represent due to `max_path_length'
ERROR: In:
ERROR: [11] '$absolute_file_name'('1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',_4810)
ERROR: [9] toplevel_call(user:user: ...) at c:/programs/swi-prolog_8.4.2/boot/toplevel.pl:1158
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
According to Microsoft the PATH_MAX limit is 260 As I understand it, this may be disabled in Windows 10 through the registry. Is it disabled by default in Windows 11? When disabled the max seems to be 32K with an additional max for each component (how high?).
There are probably fairly easy quick work-arounds, i.e., by overruling PATH_MAX while a more principled fix will require some real work. If this is commercial work, please contact me using a personal message.
I get same result using Windows 11 with SWI-Prolog 8.5.5.
I can’t remember the exact details but one should be able to use a Windows symbolic link (guide) for the part of the path that does not change then hopefully the reminder of the path is less than the 260 character limit.
The C header files define PATH_MAX as 260. This doesn’t seem to (always) apply to Windows itself. SWI-Prolog however uses PATH_MAX. If we redefine that we may hit limits further down the pipeline. For some of this, these are the MSVC somewhat POSIX compliant runtime functions. Other parts of the file system API call the Windows native Win32 API.
Raising it a bit should be harmless. Raising the limit to 32K requires some care at several places as some of the functions processing paths allocate several PATH_MAX arrays of wide characters on the C stack while the Windows stacks are by default rather small.
Welcome to SWI-Prolog (threaded, 64 bits, version 9.1.4-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
on a Mac (m2), I get the same error!
Has anyone found a workaround for this?
Windows and the rest pretty much have distinct code for handling this stuff. Most systems I’m aware of do have a limit on the path length (PATH_MAX). If somehow that is not correctly picked up the system assumes 1024. So, what call exactly are you making?
Sorry for my late response.
Actually, I was using exists_file/1.
But after more careful checking, I found that I was using a recursive clause which created ever longer paths, and then at some point hit this limit.
After verification of my system’s files, I would conclude, that from a practical point of view, the Max_path_length limit is a non issue.
Sorry for bothering you with this.