SWI-Prolog / swipl-devel

SWI-Prolog Main development repository
http://www.swi-prolog.org
Other
946 stars 171 forks source link

Windows installer unable to modify PATH #450

Open ErikHumphrey opened 5 years ago

ErikHumphrey commented 5 years ago

image

Why did the installer have trouble adding C:\Program Files\swipl\bin to PATH? That doesn't seem to be too many characters. I don't have much added to my PATH.

brunoyb commented 5 years ago

I'm getting this exact same error.

OS: Microsoft Windows 10 Pro (Version 1809) Installer: SWI-Prolog 8.0.2-1 for Microsoft Windows (64 bit)

I'm able to reproduce it just by enabling "Add swipl to the system PATH for all users" in the installer.

After the copy phase I get the following error message:

Warning! PATH too long installer unable to modify PATH!

Although it gives me an error, I'm able to add it manually to my PATH variable.

Currently my PATH have 1990 characters, which seems to be fine for Windows 7+.

C:\WINDOWS\system32> $env:PATH.Length
1990

image

Any chance of this being looked over? Thanks!

JanWielemaker commented 5 years ago

This is ultimately caused by a 1024 chars length limit on the NSIS installer string variables as I understand it. The installer is built from the CMake file NSIS.template.in, which defines an NSIS function AddToPath.

It is easy enough to find references to this problem. There are also several suggestions for work-arounds. I'm not that much of an NSIS/Windows expert to judge the proper way forward. Suggestions are welcome. One of the suggestions is to use a special build NSIS. The installer generator uses the NSIS cross toolchain on Ubuntu. Not sure how simple it is to get the special built version of that.

Note that SWI-Prolog doesn't need to be in PATH to run. This is mostly handy for usage from a console, running under e.g., Emacs or if you embed SWI-Prolog into some other language,

The work around is to edit PATH by hand ...

brunoyb commented 5 years ago

Thank you for your response!

I'm thinking about adopting the chocolatey package for swi-prolog. I'm still deciding if the package will add to PATH by default or not, but I should be able to workaround this issue there though, if needed.

EricGT commented 5 years ago

I use SWI-Prolog on Windows 10 daily and had the same problem with the 1024 character limit. As noted by Jan there are many suggestions but the one I went with and that has worked seamlessly since first using it years ago is

For System variables add a new system variable that will extend the path, e.g. PATH_EXTENDED. Don't know if it has to be exactly that, that is what I have.

In Path add %PATH_EXTENDED%.

Now you have another 1024 characters for the path.

I tested this with C:\Program Files\swipl\bin under PATH_EXTENDED and it worked to open swipl.exe from the command line.

However that is not my normal way of starting SWI-Prolog. My main way is to have it as an icon on the task bar. I am more of a mouse driver than one who memorizes keyboard command.

JanWielemaker commented 5 years ago

That is not an option to fix the installer, no? We could also opt to do it from Prolog. See e.g., https://stackoverflow.com/questions/8358265/how-to-update-path-variable-permanently-from-cmd-windows

SWI-Prolog can change the registry. It cannot send the WM_SETTINGCHANGE message, but that is easily added. We could then add this to the swipl-win.exe settings menu. That would require you to run Prolog with administrator rights to do this. It could be made smart and first figure out whether there is another version of SWI-Prolog already on PATH, etc. Would that make sense?

EricGT commented 5 years ago

That is not an option to fix the installer, no?

You are right. My mistake.

EricGT commented 5 years ago

Would that make sense?

Don't know. Since I have never had the problem and can't reproduce it I can't drill down into it to verify/find the root cause and use that to verify a fix. Also I don't regularly create software for installation on other systems. Every thing you note makes sense.

I will keep eye out for this on my radar and if I see something will get back. It may never come up on my radar but as we know once you are aware of something you sometimes start to see it everywhere.

xpxaxsxi commented 5 years ago

Nullsoft Install System v3.04-1 installation program for SWI-Prolog (threaded, 64 bits, version 8.1.13) did add Swipl to PATH-variable for all users just 5 minutes ago. On my Windows 10 Home.

Well my original path for all users was just 259 characters long. In Windows 10 there is also a user path, maybe it could be used when system path is too long??

I made a long system path from 5 copies of my original path, so I can confirm that a 1300 characters long system path caused the installation program to show a error message. So I added a text "c:\program files\swipl\bin" manually to system path, no problems with manually adding a path.

xpxaxsxi commented 5 years ago

This works on my Windows 10 Home, ^ is a escaping character in Windows cmd.exe setx PATH ^"%path%;C:\Program Files\swipl\bin^" /M