Bug 254650

Summary: lang/lua*: Installation of some Lua packages result in multiple/additional Lua versions to be installed
Product: Ports & Packages Reporter: parv <parv.0zero9+freebsd>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed Not A Bug    
Severity: Affects Only Me CC: andrew, fiziologus, freebsd, john, kevans, lx, marcus, nicklaus.t, osa, parv.0zero9+freebsd, russ.haley
Priority: --- Keywords: needs-qa
Version: LatestFlags: koobs: maintainer-feedback? (russ.haley)
koobs: maintainer-feedback? (kevans)
koobs: maintainer-feedback? (john)
nicklaus.t: maintainer-feedback-
Hardware: Any   
OS: Any   

Description parv 2021-03-30 00:40:42 UTC
I want to install some of the Lua packages available which look interesting per description as I start with my Lua learning. I had directly installed lang/lua54 package. Installation of net/wireshark also installed lua52 as dependency.


Currently installed Lua packages (with "lua" in name) ...

% pkg info -x --origin lua
lua52-5.2.4                    lang/lua52
lua54-5.4.2                    lang/lua54
luajit-2.0.5_5                 lang/luajit


When I try to install some other Lua packages, in this instance, security/luasec, its installation would also instal lang/{lua51,lua53} ...

% pkg install security/luasec
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 7 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        libglvnd: 1.3.2
        lua51: 5.1.5_9
        lua51-luasec: 0.9_1
        lua52-luasec: 0.9_1
        lua53: 5.3.6
        lua53-luasec: 0.9_1
        lua54-luasec: 0.9_1

Number of packages to be installed: 7

The process will require 7 MiB more space.
557 KiB to be downloaded.

Proceed with this action? [y/N]: n


Other offending Lua packages that I encountered which try to additionally install lua51 & lua53 ...

  devel/luafilesystem
  devel/lua-stdlib


At least devel/luafilesystem, devel/lua-stdlib, & security/luasec packages should be available so that they would be installed only for the (supported) & already installed versions of lang/lua* (lua52 & lua54 in this case); and would not cause installation of currently not installed versions of lang/lua* (lua51 & lua53 in this case).
Comment 1 parv 2021-03-30 01:12:08 UTC
Please allow me to rephrase the last paragraph ...

At least devel/luafilesystem, devel/lua-stdlib, & security/luasec packages should be available so that they would be installed only for the (supported) already installed versions of lang/lua* (lua52 & lua54 have been already installed in this case; lang/lua52 seems to be the only one supported); and would not cause installation of currently not installed versions of lang/lua* (lua51 & lua53 in this case).
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2021-03-30 02:44:17 UTC
^Triage: Loop in lang/lua* maintainers.

This appears to be a question of what lua-consuming ports specifically/explicitly depend on, or the Lua versions they specifically support, and a "works as intended " in the same vein as Python packages support specific subsets/ranges of versions, requiring multiple Python language versions to be installed. Is this analysis correct?
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2021-03-30 02:48:48 UTC
^Triage: Lua doesn't currently exist, thought we have several people working on and contributing to the Lua ports ecosystem. Reset assignee accordingly.
Comment 4 Andrew "RhodiumToad" Gierth 2021-03-30 15:58:30 UTC
So the issue here is that the port origin "security/luasec" actually builds four packages, one for each supported lua version, and "pkg install security/luasec" is an explicit request to install all four, not just the ones matching the already installed lua versions.

"pkg install lua52-luasec lua54-luasec" would install just the two specified versions.

This behavior (having each port origin build packages for every version) is necessary in order to satisfy dependencies from other ports. For example, a package which supports only lua53 and requires luasec will have a dependency on lua53-luasec (built from security/luasec@lua53). In such a case, you would need the lua53 language package to be brought in even if not already installed.

lua52 is the current "default" version (see Mk/bsd.default-versions.mk) which means that many prebuilt packages will depend on it (but not all, because not all ports support lua 5.2 and those that don't will build with the nearest version that they support).

(tl,dr: works as designed, no bug here)
Comment 5 parv 2021-03-31 02:58:05 UTC
> So the issue here is that the port origin "security/luasec" actually
> builds four packages, one for each supported lua version, and "pkg
> install security/luasec" is an explicit request to install all four,
> not just the ones matching the already installed lua versions.
>
> "pkg install lua52-luasec lua54-luasec" would install just the two
> specified versions.

Thanks for the pointer.

So one cannot simply rely on Ports tree structure anymore to generally
install a package simply based on the port directory hierarchy; really
would have to search first to find available packages (& make judgement
calls based on package names) to avoid extraneous software.

Or, one could just try to install from Ports (unless Rust); adjust
installed software after the fact if so desired.


> This behavior (having each port origin build packages for every version)
> is necessary in order to satisfy dependencies from other ports. For
> example, a package which supports only lua53 and requires luasec will have
> a dependency on lua53-luasec (built from security/luasec@lua53). In such
> a case, you would need the lua53 language package to be brought in even
> if not already installed.
...

Of course, I do not have any issue with dependency requirements+solution as mentioned.
Comment 6 Mina Galić freebsd_triage 2023-05-21 14:02:24 UTC
would be nice if pkg knew about flavours, and so we could pkg install category/port@default

but for now, this is working as designed, and not a bug