I have a SWI-Prolog version 6.0.2 for x86_64-linux previously
installed on my Ubuntu 18.04.4LTS.
I want to uninstall this version and install a 7.2.x version or higher, my motivation being to use PySwip to use prolog with my python program.
I installed a devel version using the instructions in Installing from PPA (Ubuntu Personal Package Archive)
I got notified that the newer version is installed. But I am not able to switch to this version as when I execute
swipl --version, I still get the older version. Do I need to change any environment variables? If I need to add to the PATH variable, what path should I add?
which swipl return?
That should give you an idea of where to look.
Dear @EricGT ,
Thank you for your suggestion.
which swipl returns
/usr/local/bin/swipl as does
which swipl --all
I then executed
dpkg -S $(which swipl) and got
dpkg-query: no path found matching pattern /usr/local/bin/swipl.
I was hoping to find the package name so that I could execute
dpkg -L <packagename> to find the files and search for similar files in other directories.
Without much clarity, I also tried
dpkg -L swi-prolog-nox as I saw this package name mentioned in another topic of this discourse group. But I got
Package 'swi-prolog-nox' does not contain any files (!) .
Did you mean to use
which -a swipl which is different?
The things that I don’t know for certain that might cause a problem:
Are links being used in either the old or the new install?
Are the necessary files of the old install in a single directory?
I am quite familiar with installing SWI-Prolog as a clean install on Windows and Linux but I have never tried to uninstall a version on Linux before 7.x. After reading your question I did a fresh install using the instructions you noted on Ubuntu 20.x running on WSL on Windows.
These should help you see what and new install of SWI-Prolog on Linux should look like.
root@System:~# which swipl /usr/bin/swipl root@System:~# which -a swipl /usr/bin/swipl /bin/swipl
If I use
ls -la /usr/bin/swi* this is the result
root@System:~# ls -la /usr/bin/swi* lrwxrwxrwx 1 root root 40 Jun 22 06:12 /usr/bin/swipl -> ../lib/swi-prolog/bin/x86_64-linux/swipl lrwxrwxrwx 1 root root 43 Jun 22 06:12 /usr/bin/swipl-ld -> ../lib/swi-prolog/bin/x86_64-linux/swipl-ld
The real location for the executable on Linux is
root@System:/usr/lib/swi-prolog/bin/x86_64-linux# ls -la total 60 drwxr-xr-x 2 root root 4096 Jun 29 09:13 . drwxr-xr-x 3 root root 4096 Jun 29 09:13 .. -rwxr-xr-x 1 root root 14488 Jun 22 06:12 swipl -rwxr-xr-x 1 root root 35160 Jun 22 06:12 swipl-ld
and this shows that the file is an executable and not a link or something else.
root@System:/usr/lib/swi-prolog/bin/x86_64-linux# file swipl swipl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3ac36635b238ba8597050b718d9c5bb5d8907faa, for GNU/Linux 3.2.0, stripped
As for using
dpkg when installing SWI-Prolog I have never had the need. The reason being as when I install on Linux I typically just destroy the old version of Linux as it sits on WSL and is just a set of files in a directory. So I can’t be of help with
As for the
nox version, the only info I know of that might also help is in this topic,
My best guess is that you have a link somewhere in the search path that is pointing to the old version. Since you don’t need the old version, just rename it and try the
swipl command again and when it fails it should give you a clue as to what to remove/change next. Just keep fixing until the
swipl command works as expected and then delete all of the renamed files and unnecessary links.
At this point there is not much more help I can give.
/usr/local suggests an old installation from source. Unless built with special options, a SWI-Prolog installation is a single directory in the
lib sub tree (for Unix-like systems) with two (older 3 or four) symbolic links for the executables from the
bin directory. So, do
to find the executable (was once called just
ls -l $(which swipl)
to see where it points to. That should be something like
/usr/local/lib/swipl/bin/x86_64-linux/swipl. This means the install dir is
/usr/local/lib/swipl, so simply run
rm -r /usr/local/lib/swipl
and remove the dead links from
Note that the details may vary. The main dir can be called swipl-x.y.z if the version is included, the base name can be
swi-prolog, etc. This depends on the version and how it was configured originally.
I do my build with these options (I have
$HOME/.local/bin in my
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local -G Ninja .. ninja ctest -j5 ninja install
I can delete the installed files by
rm $(cat $HOME/src/swipl-devel/build/install_manifest.txt)
install_manifest.txt file can give you a good idea of what to delete from your
Dear @EricGT ,
Thank you for your reply. And thank you for pointing out my mistake in the command
which swipl -all. I tried
which -a swipl and got the second file which is of the version that I want. I then changed the PATH to prioritize this file.
Apologies for the trouble and thank you again for such detailed information and steps.
It was no trouble at all.
I learned a few things from the post by Jan and Peter.
I wonder what went wrong? Peter’s trick works with recent versions that have been build using CMake (and provided you did not remote the build directory). 6.0.2 surely was not
Your steps worked and I was able to remove the older version. I just wanted to learn more, so wanted to try Peter’s suggestion as well.