# Pack\_install upgrade doesn't work

**URL:** <https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394>\
**Category:** Installing\
**Created:** [October 15, 2019, 4:55pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394 "2019-10-15T16:55:32Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 15, 2019, 4:55pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/1 "2019-10-15T16:55:33Z")

</div>

`pack_install(..., [upgrade(true)])` doesn’t upgrade for both `rdet` and `logtalk`.

The work-around is to find all files and directories in `~/.local` with the pack name and delete them.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 15, 2019, 5:13pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/2 "2019-10-15T17:13:23Z")

</div>

```prolog
$ swipl -q
1 ?- pack_install(logtalk, [interactive(false), upgrade(true)]).
pack_install(logtalk, [interactive(false), upgrade(true)]).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% Pack `logtalk' is already installed @3.30.0
true.

$ rm -rf ~/.local/share/swi-prolog/pack/logtalk rm -rf ~/.local/share/swi-prolog/pack/Downloads/logtalk-*
$ swipl -q
1 ?- pack_install(logtalk, [interactive(false), upgrade(true)]).
pack_install(logtalk, [interactive(false), upgrade(true)]).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "logtalk-3.31.0.tgz" was downloaded 2 times
Package: logtalk
Title: Logtalk - Object-Oriented Logic Programming Language
Installed version: 3.31.0
Author: Paulo Moura <pmoura@logtalk.org>
Maintainer: Paulo Moura <pmoura@logtalk.org>
Packager: Paulo Moura <pmoura@logtalk.org>
Home page: https://logtalk.org/
Download URL: https://logtalk.org/files/swi-prolog/packs/logtalk-3.31.0.tgz
true.

```

---

<div class="post-metadata">

**Author:** ![pmoura](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pmoura/32/11_2.png) [@pmoura](https://swi-prolog.discourse.group/u/pmoura)\
**Post date:** [October 15, 2019, 5:18pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/3 "2019-10-15T17:18:21Z")

</div>

Thanks for reporting. I don’t think it’s an issue in any of the packs. I looked into the pack files for Logtalk and their data seems correct. I would guess the same for the `rdet` pack. Maybe some issue with the recent changes to pack location?

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 15, 2019, 5:31pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/4 "2019-10-15T17:31:37Z")

</div>

I had previously removed all the “pack” files from `/usr/lib/swi-prolog` and had re-installed all my packs (which went into `~/.local/share/swi-prolog/pack`).

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 16, 2019, 1:40am UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/5 "2019-10-16T01:40:35Z")

</div>

Note that upgrade works using the wildchart URL in the pack description: it asks for the page after removing the file pattern, expecting an HTML page with links where it gets all links that match the pattern, computes the versions and compares the latest version to the installed.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 16, 2019, 5:18am UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/6 "2019-10-16T05:18:51Z")

</div>

> [@jan](#):
>
> upgrade works using the wildchart URL in the pack description

When I look at the [rdet pack page](https://www.swi-prolog.org/pack/list?p=rdet), I see that its URL has changed between github and [rlaanemets.com](http://rlaanemets.com) … would that account for the problems with upgrading that package?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 16, 2019, 1:29pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/7 "2019-10-16T13:29:07Z")

</div>

The pack.pl file doesn’t provide a download URL pattern as specified in [https://www.swi-prolog.org/howto/PackInfo.html](https://www.swi-prolog.org/howto/PackInfo.html). Older version used a git download and this upgrade simply means `git pull`.

---

<div class="post-metadata">

**Author:** ![pmoura](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pmoura/32/11_2.png) [@pmoura](https://swi-prolog.discourse.group/u/pmoura)\
**Post date:** [October 16, 2019, 1:49pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/8 "2019-10-16T13:49:10Z")

</div>

Fixed in the current git version for the Logtalk packs ([https://github.com/LogtalkDotOrg/logtalk3/commit/f7e093e4c58520b7c8f0f78b4bb231b10ca9de09](https://github.com/LogtalkDotOrg/logtalk3/commit/f7e093e4c58520b7c8f0f78b4bb231b10ca9de09)).

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 20, 2019, 10:12pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/9 "2019-10-20T22:12:50Z")

</div>

Still not working (for logtalk 3.30.0 -\> 3.31.0):

```prolog
?- pack_install(logtalk, [upgrade(true)]).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% Pack `logtalk' is already installed @3.30.0
true.

?- pack_remove(logtalk).
% Removing '/home/peter/.local/share/swi-prolog/pack/logtalk' and contents
true.

?- pack_install(logtalk, [upgrade(true)]).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install logtalk@3.31.0 from https://logtalk.org/files/swi-prolog/packs/logtalk-3.31.0.tgz Y/n?
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "logtalk-3.31.0.tgz" was downloaded 5 times
Package: logtalk
Title: Logtalk - Object-Oriented Logic Programming Language
Installed version: 3.31.0
Author: Paulo Moura <pmoura@logtalk.org>
Maintainer: Paulo Moura <pmoura@logtalk.org>
Packager: Paulo Moura <pmoura@logtalk.org>
Home page: https://logtalk.org/
Download URL: https://logtalk.org/files/swi-prolog/packs/logtalk-3.31.0.tgz
Install "logtalk-3.31.0.tgz" (17,242,461 bytes) Y/n?
true.

```

---

<div class="post-metadata">

**Author:** ![pmoura](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pmoura/32/11_2.png) [@pmoura](https://swi-prolog.discourse.group/u/pmoura)\
**Post date:** [October 20, 2019, 10:44pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/10 "2019-10-20T22:44:01Z")

</div>

The fix I mentioned in in the Logtalk **git** version. The packs are only created for stable versions. It should work when the next Logtalk stable version (3.32.0) is released (expected in November).

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 20, 2019, 11:34pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/11 "2019-10-20T23:34:36Z")

</div>

But shouldn’t `upgrade(true)` _always_ get a new version, regardless of what the current version is? There’s nothing displayed about stable vs non-stable version, as far as I can tell; and nothing I could find in the SWI-Prolog documentation about stable/non-stable.

---

<div class="post-metadata">

**Author:** ![pmoura](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pmoura/32/11_2.png) [@pmoura](https://swi-prolog.discourse.group/u/pmoura)\
**Post date:** [October 21, 2019, 8:13am UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/12 "2019-10-21T08:13:12Z")

</div>

The bug, as Jan mentioned, is that the existing packs contain a fixed URL for the specific version instead of the URL _pattern_ required for the upgrade to work. My reference to “stable” was about Logtalk stable vs git (i.e. development) versions, not SWI-Prolog. I.e., rephrasing, the packs are only created for Logtalk stable versions.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [October 21, 2019, 5:35pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/13 "2019-10-21T17:35:42Z")

</div>

Do I understand you correctly – that if the URL in the currently installed version of a package isn’t of a particular form, then upgrade won’t work? That seems to be a design bug.  
(And it also means that if the package is moved to a different server, then upgrade won’t work.)

---

<div class="post-metadata">

**Author:** ![pmoura](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pmoura/32/11_2.png) [@pmoura](https://swi-prolog.discourse.group/u/pmoura)\
**Post date:** [October 21, 2019, 5:50pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/14 "2019-10-21T17:50:29Z")

</div>

That’s my understanding from Jan’s reply, the documentation he mentioned, and from looking into the URLs of other packs.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 23, 2019, 11:29am UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/15 "2019-10-23T11:29:23Z")

</div>

The pack system was designed to work without a central authority. Using a URL pattern to fetch a new version allows for that. The price is indeed that you cannot migrate to another server. The central database that keep track of packs being downloaded can do so, but after some issues the rules were tightened not to allow registering a new version from a different location as well.

I think the current pack system is a bit too simple. It did prove the need for one and I guess it is time for some redesign …

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 2, 2021, 8:36pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/16 "2021-08-02T20:36:04Z")

</div>

I just tried the upgrade option … nothing happened for `logtalk` or `tap`. When I did a pack\_remove/1 + pack\_install/1, I got the new version.

(I had forgotten about pack\_upgrade/1 and I don’t know how to install an older version so that I can try again)

Also, the options don’t seem to be checked for validity – I used `update(true)` by mistake and there was no complaint.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [August 3, 2021, 3:16pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/17 "2021-08-03T15:16:07Z")

</div>

I don’t know about the upgrade issue. Don’t seem to have any out-of-date packages. You should be able to install an old one by providing the download location explicitly.

> [@peter.ludemann](#):
>
> Also, the options don’t seem to be checked for validity – I used `update(true)` by mistake and there was no complaint.

By design, SWI-Prolog predicates that process options do not complain about options they do not understand. This largely simplifies writing a new predicate that processes options and calls other predicates that process options we can now simply pass the option list around. Otherwise we have to know which predicates accept which options and filter for each call. It also provides a bit smoother path adding options. Of course, the downside is that if you need to rely on a predicate processing some option and you either mistype or this version of the predicate doesn’t support this option you are in trouble. In other words, you should consider options much like environment variables.

The IDE tools use the predicate\_options/3 declarations to highlight unknown options or wrong types. There is also check\_predicate\_options/0 to warn about option issues. Note that this only works for options that are directly passed to predicates that have an option declaration, i.e., not for dynamically assembled option lists.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 3, 2021, 6:09pm UTC](https://swi-prolog.discourse.group/t/pack-install-upgrade-doesnt-work/1394/18 "2021-08-03T18:09:54Z")

</div>

> [@jan](#):
>
> simplifies writing a new predicate that processes options and calls other predicates that process options we can now simply pass the option list around

Agreed that this make sense; maybe an additional `update` option with the same meaning would help avoid errors. 😉

Anyway, here’s a demonstration of pack\_install/2 with `upgrade` not working but pack\_upgrade/1 works:

```prolog
?- pack_info(edcg).
Package: edcg
Title: Extended DCG
Installed version: 0.9.1.6
Installed in directory: /home/peter/.local/share/swi-prolog/pack/edcg
Author: Peter Van Roy <peter.vanroy@uclouvain.be>
Maintainer: Peter Ludemann <peter.ludemann@gmail.com>
Packager: Michael Hendricks <michael@ndrix.org>
Home page: https://github.com/kamahen/edcg
Download URL: https://github.com/kamahen/edcg/archive/*.zip
Provided libraries: edcg
true.

```

pack\_install/2 with `upgrade` does nothing:

```prolog
?- pack_install(edcg, [upgrade(true)]).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% Pack `edcg' is already installed @0.9.1.6
true.

```

pack\_upgrade/1 works, although it outputs a mysterious error message:

```prolog
?- pack_upgrade(edcg).
Upgrade "edcg" from 0.9.1.6 to 0.9.1.7 Y/n? y
Verify package status (anonymously)
	at "https://www.swi-prolog.org/pack/query" Y/n? 
% Contacting server at https://www.swi-prolog.org/pack/query ...
ERROR: Server reported the following error:
ERROR: No permission to register pack(edcg) `'https://api.github.com/repos/kamahen/edcg/zipball/refs/tags/v0.9.1.7''
Package: edcg
Title: Extended DCG
Installed version: 0.9.1.7
Author: Peter Van Roy <peter.vanroy@uclouvain.be>
Maintainer: Peter Ludemann <peter.ludemann@gmail.com>
Packager: Michael Hendricks <michael@ndrix.org>
Home page: https://github.com/kamahen/edcg
Download URL: https://github.com/kamahen/edcg/archive/*.zip
Install "edcg-0.9.1.7" (730,184 bytes) Y/n? 
true.

```

However, despite the error message, the upgrade appears to have worked:

```prolog
?- pack_info(edcg).
Package: edcg
Title: Extended DCG
Installed version: 0.9.1.7
Installed in directory: /home/peter/.local/share/swi-prolog/pack/edcg
Author: Peter Van Roy <peter.vanroy@uclouvain.be>
Maintainer: Peter Ludemann <peter.ludemann@gmail.com>
Packager: Michael Hendricks <michael@ndrix.org>
Home page: https://github.com/kamahen/edcg
Download URL: https://github.com/kamahen/edcg/archive/*.zip
Provided libraries: edcg
true.

```
