Broken installation

89 views
Skip to first unread message

Sam Neaves

unread,
Jun 14, 2017, 7:45:32 AM6/14/17
to SWI-Prolog
I have a computer (Raspberry Pi)  that when I launch 'swipl' I get version 7.5.8 but if I launch 'sudo swipl' I get version 7.3. 

How do I fix this?

This happened when I tried to update with: 

make distclean
git pull
./prepare
./build

I have tried doing that again and it is still broken.

Thanks 

Sam

Jan Wielemaker

unread,
Jun 14, 2017, 7:53:03 AM6/14/17
to Sam Neaves, SWI-Prolog
Hi Sam,

Most like $PATH is different for root than for you and you have
two installed systems. Try `which swipl` and `sudo which swipl`.
Either specify the correct one with an absolute path, adjust $PATH
or remove the old version.

Cheers --- Jan
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

Sam Neaves

unread,
Jun 14, 2017, 9:11:31 AM6/14/17
to Jan Wielemaker, SWI-Prolog
Hi Jan thanks for the reply.

How do I find where the old version is installed? Do I just remove the directory to uninstall it? 

Thanks Sam



On Wed, Jun 14, 2017 at 12:52 PM, Jan Wielemaker <J.Wiel...@vu.nl> wrote:
Hi Sam,

Most like $PATH is different for root than for you and you have
two installed systems.  Try `which swipl` and `sudo which swipl`.
Either specify the correct one with an absolute path, adjust $PATH
or remove the old version.

        Cheers --- Jan


On 06/14/2017 01:45 PM, Sam Neaves wrote:
I have a computer (Raspberry Pi)  that when I launch 'swipl' I get version 7.5.8 but if I launch 'sudo swipl' I get version 7.3.

How do I fix this?

This happened when I tried to update with:

make distclean
git pull
./prepare
./build

I have tried doing that again and it is still broken.

Thanks

Sam

--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com <mailto:swi-prolog+unsubscribe@googlegroups.com>.

Jan Wielemaker

unread,
Jun 14, 2017, 10:40:57 AM6/14/17
to Sam Neaves, SWI-Prolog
On 06/14/2017 03:10 PM, Sam Neaves wrote:
> Hi Jan thanks for the reply.
>
> How do I find where the old version is installed? Do I just remove the
> directory to uninstall it?

Depends how it is installed. If it is installed through the OS
package manager, use that to delete it. If it is installed from
the source there is a directory that holds the whole thing and
typically links from the public /bin to the binaries. To find
this directory, start Prolog and do

?- current_prolog_flag(home, X).

Cheers --- Jan
> it, send an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog%2Bunsu...@googlegroups.com>
> <mailto:swi-prolog+...@googlegroups.com
> <mailto:swi-prolog%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/group/swi-prolog>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>

Sam Neaves

unread,
Jun 15, 2017, 2:37:09 AM6/15/17
to Jan Wielemaker, SWI-Prolog
Sorry I am still having a lot of trouble with this.
I think I have made it worse.

Currently:

'which swipl' 
 /home/pi/bin/swipl

'which sudo swipl'
 /usr/bin/sudo
/home/pi/bin/swipl 


$sudo swipl
sudo: swipl: command not found

$swipl 
Welcome to SWI-Prolog (threaded, 32 bits, version 7.5.9)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).


?- current_prolog_flag(home,X).
X = '/home/pi/lib/swipl-7.5.9'.


?- check_installation.
% Checking your SWI-Prolog kit for common issues ...
% Version: ............. 7.5.9
% Address bits: ........ 32
% Architecture: ........ armv6l-linux
% Installed at: ........ /home/pi/lib/swipl-7.5.9
% Cores: ............... 1
% Checking gmp ................................. ok
% Loading library(archive) ..................... ok
%   Supported filters: bzip2, compress, gzip, lzip, lzma, none, rpm, uu, xz
%   Supported formats: 7zip, ar, cab, cpio, empty, gnutar, iso9660, lha, mtree, rar, raw, tar, xar, zip
% Loading library(cgi) ......................... ok
% Loading library(crypt) ....................... ok
% Loading library(bdb) ......................... ok
% Loading library(double_metaphone) ............ ok
% Loading library(filesex) ..................... ok
% Loading library(http/http_stream) ............ ok
% Loading library(http/json) ................... ok
% Loading library(isub) ........................ ok
% Loading library(jpl) ......................... FAILED
Warning: Cannot load required shared library
% Loading library(memfile) ..................... ok
% Loading library(odbc) ........................ ok
% Loading library(pce) ......................... ok
Warning: library(pcre) ......................... NOT FOUND
% Loading library(pdt_console) ................. ok
% Loading library(porter_stem) ................. ok
% Loading library(process) ..................... ok
Warning: library(editline) ..................... NOT FOUND
% Loading library(readline) .................... ok
% Loading library(readutil) .................... ok
% Loading library(rlimit) ...................... ok
% Loading library(semweb/rdf_db) ............... ok
% Loading library(semweb/rdf_ntriples) ......... ok
% Loading library(semweb/turtle) ............... ok
% Loading library(sgml) ........................ ok
% Loading library(sha) ......................... ok
% Loading library(snowball) .................... ok
% Loading library(socket) ...................... ok
% Loading library(ssl) ......................... ok
% Loading library(syslog) ...................... ok
% Loading library(table) ....................... ok
% Loading library(time) ........................ ok
% Loading library(tipc/tipc) ................... ok
% Loading library(unicode) ..................... ok
% Loading library(uri) ......................... ok
% Loading library(uuid) ........................ ok
% Loading library(zlib) ........................ ok
Warning: Found 3 issues.
true.


Also if I try and load libraries I now get errors.


ERROR: /home/pi/Desktop/website/basic_site.pl:1:
source_sink `library(http/thread_httpd)' does not exist

ERROR: /home/pi/Desktop/website/basic_site.pl:2:
source_sink `library(http/http_dispatch)' does not exist

etc


The contents of the relevant folder are:

~/lib $ ls
pkgconfig  swipl-7.5.9

/home/pi/bin $ls
swipl  swipl-ld  swipl-rc  xpce-client

/bin $ ls | grep swipl
nothing


I have tried rebuilding it multiple times (which takes a long time on the pi!) and I am pretty frustrated. 

I have always installed SWI by cloning the git folder to the desktop and running through the build instructions there.

Any further help much appreciated.

Sam




Thanks Sam

Jan Burse

unread,
Jun 15, 2017, 3:18:49 AM6/15/17
to SWI-Prolog
typo:
which sudo swipl --> sudo which swipl

Am Donnerstag, 15. Juni 2017 08:37:09 UTC+2 schrieb sam.neaves:

Jan Wielemaker

unread,
Jun 15, 2017, 3:25:16 AM6/15/17
to Sam Neaves, SWI-Prolog
On 06/15/2017 08:36 AM, Sam Neaves wrote:
> Sorry I am still having a lot of trouble with this.
> I think I have made it worse.
>
> Currently:
>
> 'which swipl'
> /home/pi/bin/swipl
>
> 'which sudo swipl'
> /usr/bin/sudo
> /home/pi/bin/swipl

But this looks for sudo and swipl from your user. I asked
(I hope I did) for sudo which swipl, which runs which swipl
as root. You can also do

sudo swipl
?- current_prolog_flag(home, Home).
?- current_prolog_flag(executable, Exe).

> $sudo swipl
> sudo: swipl: command not found

Oh, it can't find it. I thought you said it found a different
version? It can't find it because your bin directry is not in
root's search path. Simply do sudo /home/pi/bin/swipl
That looks close to ok. You need to install all dependencies
for the other three libraries if you need them.

> Also if I try and load libraries I now get errors.
>
>
> ERROR: /home/pi/Desktop/website/basic_site.pl:1 <http://basic_site.pl:1>:
> source_sink `library(http/thread_httpd)' does not exist
>
> ERROR: /home/pi/Desktop/website/basic_site.pl:2 <http://basic_site.pl:2>:
> source_sink `library(http/http_dispatch)' does not exist

That is a little weird as chech installation can find them. Is this the
same session, did you start it differently, are there environment
variables liki SWI_PROLOG_HOME defined?

> etc
>
>
> The contents of the relevant folder are:
>
> ~/lib $ ls
> pkgconfig swipl-7.5.9

ok
>
> /home/pi/bin $ls
> swipl swipl-ld swipl-rc xpce-client

ok

>
> /bin $ ls | grep swipl
> nothing

Seems good to me as well.

> I have tried rebuilding it multiple times (which takes a long time on
> the pi!) and I am pretty frustrated.
>
> I have always installed SWI by cloning the git folder to the desktop and
> running through the build instructions there.
>
> Any further help much appreciated.

I'm mostly lost ... I think you tell only half the story and want
to do something different. For one thing, I'm unsure what is done
as root and what as user. Did you compile as root or user?

Success --- Jan

>
> Sam
>
>
>
> On Wed, Jun 14, 2017 at 3:40 PM, Jan Wielemaker <J.Wiel...@vu.nl
> <mailto:J.Wiel...@vu.nl>> wrote:
>
> On 06/14/2017 03:10 PM, Sam Neaves wrote:
>
> Hi Jan thanks for the reply.
>
> How do I find where the old version is installed? Do I just
> remove the directory to uninstall it?
>
>
> Depends how it is installed. If it is installed through the OS
> package manager, use that to delete it. If it is installed from
> the source there is a directory that holds the whole thing and
> typically links from the public /bin to the binaries. To find
> this directory, start Prolog and do
>
> ?- current_prolog_flag(home, X).
>
> Cheers --- Jan
>
>
> Thanks Sam
>
>
>
> On Wed, Jun 14, 2017 at 12:52 PM, Jan Wielemaker
> <J.Wiel...@vu.nl <mailto:J.Wiel...@vu.nl>
> swi-prolog+...@googlegroups.com
> <mailto:swi-prolog%2Bunsu...@googlegroups.com>
> <mailto:swi-prolog%2Bunsu...@googlegroups.com
> <mailto:swi-prolog%252Buns...@googlegroups.com>>
> <mailto:swi-prolog+...@googlegroups.com
> <mailto:swi-prolog%2Bunsu...@googlegroups.com>
> <mailto:swi-prolog%2Bunsu...@googlegroups.com
> <mailto:swi-prolog%252Buns...@googlegroups.com>>>.

Sam Neaves

unread,
Jun 15, 2017, 9:02:09 AM6/15/17
to Jan Wielemaker, SWI-Prolog
Sorry for not being clear. 

I think we are making progress. 

Situation at the moment: 

1.I can't run 'sudo swipl' . How do I put the directory back in the path for sudo? 
2. Running 'sudo /home/pi/bin/swipl' for a program that needs root errors.

What I have done: 
Originally I had the problem with two versions one for 'swipl' and one for 'sudo swipl'.
Then after lots of messing around trying to remove the old version and building the latest version I ended up in the situation where  
'sudo swipl' could not be found but 'swipl' loaded.

I was then trying to launch sudo swipl by specifying the path. This was the cause of the problem with the libraries not being found because I was mistakenly launching 

sudo /home/pi/Desktop/swipl-devel/src/swipl

rather than

sudo /home/pi/bin/swipl

So now- thanks to you pointing that out- it seemed that I could at least launch the sudo version by specifying the path and I dont get an error loading a library.

But when I actually try and launch my program that needs root I get an error.

sudo /home/pi/bin/swipl basic_site.pl --https --user=pi --interactive --keyfile=/var/www/samneaves.ddns.net/privkey.pem --certfile=/var/www/samneaves.ddns.net/fullchain.pem
% Started server at https://localhost:443/
ERROR: Cannot open port 443.  Only root can open ports below 1000.

I am not sure if this is related to not being able to launch 'sudo swipl' or because something has changed in the latest version of swi? 

Sorry for taking up your time with this.









Sam Neaves

unread,
Jun 15, 2017, 9:03:20 AM6/15/17
to Jan Wielemaker, SWI-Prolog
Ps I complied with Sudo

Jan Wielemaker

unread,
Jun 15, 2017, 9:21:27 AM6/15/17
to Sam Neaves, SWI-Prolog
On 15/06/17 15:01, Sam Neaves wrote:
> Sorry for not being clear.
>
> I think we are making progress.
>
> Situation at the moment:
>
> 1.I can't run 'sudo swipl' . How do I put the directory back in the path
> for sudo?

Install it globally. Normally, that implies changing in `build`:

PREFIX=/usr/local
SUDO=sudo

Do *not* run `./build` as root (your next mail). At least, normally
you shouldn't. You should only use `sudo` if you really need it. The
SUDO=sudo line above makes sure that the final installation part is
executed as root, which you need as /usr/local is normally not writeable
as ordinary user.

Given that you build it once as normal user, you either need to start
from scratch or do `sudo chown -R pi.pi swipl-devel` to make the build
environment owned by the pi user.

If you do not want to compile another time, do

mkdir -p /usr/local/bin
cd /usr/local/bin
ln -s /home/pi/bin/swipl

> 2. Running 'sudo /home/pi/bin/swipl' for a program that needs root errors.

That seems unrelated. Below.

> What I have done:
> Originally I had the problem with two versions one for 'swipl' and one
> for 'sudo swipl'.
> Then after lots of messing around trying to remove the old version and
> building the latest version I ended up in the situation where
> 'sudo swipl' could not be found but 'swipl' loaded.
>
> I was then trying to launch sudo swipl by specifying the path. This was
> the cause of the problem with the libraries not being found because I
> was mistakenly launching
>
> sudo /home/pi/Desktop/swipl-devel/src/swipl
>
> rather than
>
> sudo /home/pi/bin/swipl

Yes. Using /home/pi/Desktop/swipl-devel/src/swipl you have the not
installed core system only. You're even lucky, on some systems it
doesn't run at all prior to installation :)

> So now- thanks to you pointing that out- it seemed that I could at least
> launch the sudo version by specifying the path and I dont get an error
> loading a library.
>
> But when I actually try and launch my program that needs root I get an
> error.
>
> sudo /home/pi/bin/swipl basic_site.pl <http://basic_site.pl> --https
> --user=pi --interactive
> --keyfile=/var/www/samneaves.ddns.net/privkey.pem
> <http://samneaves.ddns.net/privkey.pem>
> --certfile=/var/www/samneaves.ddns.net/fullchain.pem
> <http://samneaves.ddns.net/fullchain.pem>
> % Started server at https://localhost:443/
> ERROR: Cannot open port 443. Only root can open ports below 1000.
>
> I am not sure if this is related to not being able to launch 'sudo
> swipl' or because something has changed in the latest version of swi?

It is quite surely not related to `sudo /home/pi/bin/swipl`. That should
be fine. I don't really know what is causing this. I assume
basic_site.pl is short enough to share it with us.

> Sorry for taking up your time with this.

You're doing a lot of excellent publicity!

Cheers --- Jan

Sam Neaves

unread,
Jun 15, 2017, 1:04:24 PM6/15/17
to Jan Wielemaker, SWI-Prolog
Thanks Jan,

Changing the build instructions to :

PREFIX=/usr/local
SUDO=sudo

Seemed to fix the installation.
But I am still getting the error about port 443. I tried setting the flag --user=root rather than pi and that results in a warning but the server starts:

pi@raspberrypi ~/Desktop/website $ sudo swipl basic_site.pl --https --user=pi --keyfile=/var/www/samneaves.ddns.net/privkey.pem --certfile=/var/www/samneaves.ddns.net/fullchain.pem  --interactive
% Started server at https://localhost:443/
ERROR: Cannot open port 443.  Only root can open ports below 1000.
pi@raspberrypi ~/Desktop/website $ sudo swipl basic_site.pl --https --user=root --keyfile=/var/www/samneaves.ddns.net/privkey.pem --certfile=/var/www/samneaves.ddns.net/fullchain.pem  --interactive
% Started server at https://localhost:443/
Warning: thread_create/3: No permission to create thread `'https@443'' (Alias name already taken)
?- 

Small  example of basic_site.pl


:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_error)).
:- use_module(library(http/html_write)).
:- use_module(library(http/http_json)).
:- use_module(library(http/http_unix_daemon)).
:- use_module(library(http/http_open)).
:- use_module(library(ssl)).
:- use_module(library(clpfd)).
:- initialization http_daemon.
:- dynamic sessionid_sentence/2.


:- http_handler('/', say_hi, []).


server(Port) :-
        http_server(http_dispatch, [port(Port)]).



say_hi(_Request) :-
        phrase(
            my_nonterm,
            TokenizedHtml,
            []),
        format('Content-type: text/html~n~n'),
        print_html(TokenizedHtml).

my_nonterm -->
        html([html([head([title('Sam Neaves homepage')]),
                    body([h1('Welcome to Sam Neaves home page'),
                          p("Please take a look at these:"),
                          h2('Publications:'),
                          iframe([width=1400, height=1500,src='http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4962912/'],'something'),
                          h2('Youtube Channel Playing with Prolog:'),
                          a(href='https://www.youtube.com/channel/UCfWpIHmy5MEx2p9c_GJrE_g', 'Youtube Playing with Prolog'),
                          h2('Remote controlling a robot with Prolog pengines:'),
                          iframe([width=1400, height=1500, src='http://swish.swi-prolog.org/p/embed' + encode(' youtube test.swinb'$

                          p('This server is powered by swi-prolog and raspberry pi!')
                        ])
                   ])
             ]).

Jan Wielemaker

unread,
Jun 15, 2017, 2:28:51 PM6/15/17
to Sam Neaves, SWI-Prolog
On 06/15/2017 07:03 PM, Sam Neaves wrote:
> Thanks Jan,
>
> Changing the build instructions to :
>
> PREFIX=/usr/local
> SUDO=sudo
>
> Seemed to fix the installation.
> But I am still getting the error about port 443. I tried setting the
> flag --user=root rather than pi and that results in a warning but the
> server starts:

Almost there. One bug by me. http_unix_daemon.pl now uses the new
toplevel entry point, which means it doesn't need `:- initialization
http_daemon.` any more. I thought it wouldn't harm still using this,
but it does if you include `--interative`. So, as from version 7.5.8,
omit this initialization directive.

... and do not use --user=root. You do not want web services running
as root.

The code can be a little more elegant, as below. The youtube thing
doesn't work, but I cannot find the page on swish either.

Cheers --- Jan

server(Port) :-
http_server(http_dispatch, [port(Port)]).

say_hi(_Request) :-
reply_html_page(
title('Sam Neaves homepage'),
[ h1('Welcome to Sam Neaves home page'),
p("Please take a look at these:"),
h2('Publications:'),
iframe([ width=1400, height=1500,

src='http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4962912/'
], []),
h2('Youtube Channel Playing with Prolog:'),

a(href='https://www.youtube.com/channel/UCfWpIHmy5MEx2p9c_GJrE_g',
'Youtube Playing with Prolog'),
h2('Remote controlling a robot with Prolog pengines:'),
iframe([ width=1400, height=1500,
src='http://swish.swi-prolog.org/p/embed' +
encode('youtube test.swinb')
], []),

p('This server is powered by swi-prolog and raspberry pi!')
]).



Sam Neaves

unread,
Jun 15, 2017, 2:37:48 PM6/15/17
to Jan Wielemaker, SWI-Prolog
Great!

Well at least we found a bug for our trouble. 

Thank you for your help in getting my little project back on track!
Reply all
Reply to author
Forward
0 new messages