Opened 16 months ago

Last modified 13 months ago

#67765 assigned defect

Change #37496 seems to have broken lua54-luarocks

Reported by: michaellenaghan (Michael Lenaghan) Owned by: l2dy (Zero King)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), mascguy (Christopher Nielsen), cooljeanius (Eric Gallager)
Port: lua54-luarocks

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Change #3749, revision here, seems to have broken lua54-luarocks in this sense:

  • Installing lua54-luarocks no longer installs the luarocks and luarocks-admin binaries

To install the luarocks binaries you have to install lua-luarocks:

$ port contents lua-luarocks

Port lua-luarocks contains:
  /opt/local/bin/luarocks
  /opt/local/bin/luarocks-5.1
  /opt/local/bin/luarocks-5.2
  /opt/local/bin/luarocks-5.3
  /opt/local/bin/luarocks-5.4
  /opt/local/bin/luarocks-admin
  /opt/local/bin/luarocks-admin-5.1
  /opt/local/bin/luarocks-admin-5.2
  /opt/local/bin/luarocks-admin-5.3
  /opt/local/bin/luarocks-admin-5.4
  /opt/local/etc/luarocks/config-5.1.lua
  /opt/local/etc/luarocks/config-5.2.lua
  /opt/local/etc/luarocks/config-5.3.lua
  /opt/local/etc/luarocks/config-5.4.lua
  /opt/local/share/luarocks/.turd_lua-luarocks

lua-luarocks forces the installation of lua53 and lua53-luarocks, which is… odd… when I'm only interested in lua54. But worse, running luarocks-5.4 actually selects lua-5.3 by default:

$ luarocks-5.4

...

Configuration:
   Lua:
      Version    : 5.3
      Interpreter: /opt/local/bin/lua5.3 (ok)
      LUA_DIR    : /opt/local/libexec/lua53 (ok)
      LUA_BINDIR : /opt/local/bin (ok)
      LUA_INCDIR : /opt/local/libexec/lua53/include (ok)
      LUA_LIBDIR : /opt/local/libexec/lua53/lib (ok)

   Configuration files:
      System  : /opt/local/etc/luarocks/config-5.3.lua (ok)
      User    : /Users/michaellenaghan/.luarocks/config-5.3.lua (not found)

...

To get the right version of lua you have to specify --lua-version 5.4 on the command-line:

$ luarocks-5.4 --lua-version 5.4

...

Configuration:
   Lua:
      Version    : 5.4
      Interpreter: /opt/local/bin/lua5.4 (ok)
      LUA_DIR    : /opt/local/libexec/lua54 (ok)
      LUA_BINDIR : /opt/local/bin (ok)
      LUA_INCDIR : /opt/local/libexec/lua54/include (ok)
      LUA_LIBDIR : /opt/local/libexec/lua54/lib (ok)

   Configuration files:
      System  : /opt/local/etc/luarocks/config-5.4.lua (ok)
      User    : /Users/michaellenaghan/.luarocks/config-5.4.lua (not found)

...

Finally, luarocks_select no longer seems to work:

$ port select --summary

Name        Selected      Options
====        ========      =======
...
luarocks    none          none
...

Change History (7)

comment:1 Changed 16 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: MarcusCalhoun-Lopez added
Description: modified (diff)
Owner: set to l2dy
Status: newassigned

comment:2 Changed 16 months ago by mascguy (Christopher Nielsen)

Cc: mascguy added

comment:3 Changed 16 months ago by michaellenaghan (Michael Lenaghan)

Just adding that you have to add --lua-version 5.4 for *any* operation that's version dependent — e.g., installing rocks.

Also, though this may be unrelated: it seems that installing luarocks via port doesn't add the appropriate luarocks paths to LUA_PATH and LUA_CPATH? I'm not positive that's correct, but it seemed that after installing some rocks I couldn't just require them in lua.

comment:4 Changed 16 months ago by l2dy (Zero King)

It was intentional that luarocks_select becomes deprecated. All luarocks* commands now uses the same Lua version (5.3 as of Jul 2023) and requires lua-luarocks to be installed, so there is nothing to select from.

Did Michael's reply address your concerns? Are you in favor of reverting the change?

comment:5 Changed 16 months ago by michaellenaghan (Michael Lenaghan)

Just to make sure we're on the same page: I understand the intent of the change. From a user perspective, I'm not sure it works. Try this:

$ sudo port install lua54
$ sudo port install lua-luarocks
$ luarocks install --local LuaFileSystem
$ lua5.4
> lfs = require("lfs")

That won't work, for two reasons.

First, as far as I can tell, installing luarocks doesn't add the luarocks paths to LUA_PATH and LUA_CPATH. Maybe that's "as designed", but it isn't obvious; the port doesn't publish any usage notes, etc. as most ports that require additional config do.

Second, and perhaps more importantly: the rock will be built and installed for lua5.3 rather than lua5.4. It's true that luarocks can build for any version. But it's also true that, by default, it builds for the version it's based on. In order to build for any *other* version, you have to specify that version — e.g. --lua-version 5.4 -- every time you do anything.

To make matters worse, luarocks still installs a bunch of versioned symlinks:

$ ls /opt/local/bin/luarocks*
/opt/local/bin/luarocks*           /opt/local/bin/luarocks-admin*
/opt/local/bin/luarocks-5.1@       /opt/local/bin/luarocks-admin-5.1@
/opt/local/bin/luarocks-5.2@       /opt/local/bin/luarocks-admin-5.2@
/opt/local/bin/luarocks-5.3@       /opt/local/bin/luarocks-admin-5.3@
/opt/local/bin/luarocks-5.4@       /opt/local/bin/luarocks-admin-5.4@

Using a versioned symlink still builds for the *default* lua version, rather than the version you selected:

$ luarocks-5.4

...

Configuration:
   Lua:
      Version    : 5.3
      Interpreter: /opt/local/bin/lua (ok)
      LUA_DIR    : /opt/local (ok)
      LUA_BINDIR : /opt/local/bin (ok)
      LUA_INCDIR : /opt/local/include (ok)
      LUA_LIBDIR : /opt/local/lib (ok)

   Configuration files:
      System  : /opt/local/etc/luarocks/config-5.3.lua (ok)
      User    : /Users/example/.luarocks/config-5.3.lua (not found)

   Rocks trees in use:
      /Users/example/.luarocks ("user")
      /opt/local/share/luarocks ("system")

and:

$ luarocks-5.4 path
export LUA_PATH='/opt/local/share/lua/5.3/?.lua;/opt/local/share/lua/5.3/?/init.lua;/opt/local/lib/lua/5.3/?.lua;/opt/local/lib/lua/5.3/?/init.lua;…'
export LUA_CPATH='/opt/local/lib/lua/5.3/?.so;/opt/local/lib/lua/5.3/loadall.so;./?.so;/Users/example/.luarocks/lib/lua/5.3/?.so;/opt/local/share/luarocks/lib/lua/5.3/?.so;…'
export PATH='/Users/example/.luarocks/bin:/opt/local/share/luarocks/bin:…'

Notice that in both cases I'm using luarocks-5.4 but seeing 5.3 in the paths.

I don't know what the previous experience was like. I just know that this one is incredibly confusing. It may be possible to make it work right, but if something doesn't change you're likely to get more tickets like this one.

P.S. It's also odd that 5.3 is the default lua? 5.4 was released in 2020. I bring that up because if luarocks was using the *latest* version then maybe fewer users would run into these problems?

comment:6 in reply to:  5 Changed 13 months ago by l2dy (Zero King)

Replying to michaellenaghan:

That won't work, for two reasons.

First, as far as I can tell, installing luarocks doesn't add the luarocks paths to LUA_PATH and LUA_CPATH. Maybe that's "as designed", but it isn't obvious; the port doesn't publish any usage notes, etc. as most ports that require additional config do.

That's as designed. You should read --help before using the --local flag.

   --local               Use the tree in the user's home directory.
                         To enable it, see '/opt/local/bin/luarocks help path'.

Second, and perhaps more importantly: the rock will be built and installed for lua5.3 rather than lua5.4. It's true that luarocks can build for any version. But it's also true that, by default, it builds for the version it's based on. In order to build for any *other* version, you have to specify that version — e.g. --lua-version 5.4 -- every time you do anything.

To make matters worse, luarocks still installs a bunch of versioned symlinks:

$ ls /opt/local/bin/luarocks*
/opt/local/bin/luarocks*           /opt/local/bin/luarocks-admin*
/opt/local/bin/luarocks-5.1@       /opt/local/bin/luarocks-admin-5.1@
/opt/local/bin/luarocks-5.2@       /opt/local/bin/luarocks-admin-5.2@
/opt/local/bin/luarocks-5.3@       /opt/local/bin/luarocks-admin-5.3@
/opt/local/bin/luarocks-5.4@       /opt/local/bin/luarocks-admin-5.4@

Using a versioned symlink still builds for the *default* lua version, rather than the version you selected:

$ luarocks-5.4

...

Configuration:
   Lua:
      Version    : 5.3
      Interpreter: /opt/local/bin/lua (ok)
      LUA_DIR    : /opt/local (ok)
      LUA_BINDIR : /opt/local/bin (ok)
      LUA_INCDIR : /opt/local/include (ok)
      LUA_LIBDIR : /opt/local/lib (ok)

   Configuration files:
      System  : /opt/local/etc/luarocks/config-5.3.lua (ok)
      User    : /Users/example/.luarocks/config-5.3.lua (not found)

   Rocks trees in use:
      /Users/example/.luarocks ("user")
      /opt/local/share/luarocks ("system")

and:

$ luarocks-5.4 path
export LUA_PATH='/opt/local/share/lua/5.3/?.lua;/opt/local/share/lua/5.3/?/init.lua;/opt/local/lib/lua/5.3/?.lua;/opt/local/lib/lua/5.3/?/init.lua;…'
export LUA_CPATH='/opt/local/lib/lua/5.3/?.so;/opt/local/lib/lua/5.3/loadall.so;./?.so;/Users/example/.luarocks/lib/lua/5.3/?.so;/opt/local/share/luarocks/lib/lua/5.3/?.so;…'
export PATH='/Users/example/.luarocks/bin:/opt/local/share/luarocks/bin:…'

Notice that in both cases I'm using luarocks-5.4 but seeing 5.3 in the paths.

I don't know what the previous experience was like. I just know that this one is incredibly confusing. It may be possible to make it work right, but if something doesn't change you're likely to get more tickets like this one.

Previously, using luarocks-5.4 will build for Lua 5.4. I was just bit by this new behavior when updating the luarocks-1.0 port group.

P.S. It's also odd that 5.3 is the default lua? 5.4 was released in 2020. I bring that up because if luarocks was using the *latest* version then maybe fewer users would run into these problems?

It follows the default version used by the lua port. We could update all of them at once.

Overall, I agree that the new behavior is suboptimal and should be reverted, but we will also need to take care not to break the new luarocks-1.1 port group and related ports.

I won't be able to work on these improvements soon, so pull requests are welcome.

comment:7 Changed 13 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.