Skip to content

support Lua 5.5 - #1844

Merged
daurnimator merged 5 commits into
luarocks:mainfrom
catwell:pr/lua-5.5
Dec 26, 2025
Merged

daurnimator merged 5 commits into
luarocks:mainfrom
catwell:pr/lua-5.5

Conversation

@catwell

@catwell catwell commented Dec 7, 2025 •

Copy link
Copy Markdown
Contributor

This PR adds initial support for Lua 5.5. With those changes I could build LuaRocks on lua-5.5.0-rc2.

@fperrad

fperrad commented Dec 7, 2025 •

Copy link
Copy Markdown
Contributor

now, we need a manifest-5.5 on https://luarocks.org

see luarocks/luarocks-site#232

@luau-project

Copy link
Copy Markdown
Collaborator

On Debian stable, I did test your changes quickly on a few packages building them from source (luarocks make <ROCKSPEC>) to work around the manifest-5.5 limitation noted by fperrad. So far, your changes allowed me ( 👍 ) to install the following packages through LuaRocks:

  • luafilesystem from GitHub HEAD with a minor edit to LFS source code:

    diff -Naur a/src/lfs.c b/src/lfs.c
    --- a/src/lfs.c	2024-10-28 17:30:52.000000000 -0300
    +++ b/src/lfs.c	2025-12-07 20:43:51.462787552 -0300
    @@ -311,7 +311,7 @@
         return 0;
       } else
         return *fh;
    -#elif LUA_VERSION_NUM >= 502 && LUA_VERSION_NUM <= 504
    +#elif LUA_VERSION_NUM >= 502 && LUA_VERSION_NUM <= 505
       luaL_Stream *fh = (luaL_Stream *) luaL_checkudata(L, idx, "FILE*");
       if (fh->closef == 0 || fh->f == NULL) {
         luaL_error(L, "%s: closed file", funcname);
  • lua-cjson from GitHub HEAD (without any change).

Still on this Lua transition subject, a while ago, I was looking at some environment variables related to Lua versions, and noticed a few places that would require attention to the 5.5.0 transition (see the changes on #1832 related to environment variables).


Just adding to the discussion another two cents: you might be interested on this #1812 (comment) about Lua 5.5 transition.

@botantony

Copy link
Copy Markdown

FYI 5.5 is out

@mrcjkb mrcjkb mentioned this pull request Dec 23, 2025
@daurnimator

Copy link
Copy Markdown
Member

@catwell could you rebase on top of main now that I pushed #1847 ? (that way we can get a proper CI check)

@catwell

catwell commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

Note that currently those changes cause warnings with Teal due to incompatible handling of for loop variables (but the resulting Lua code is fine).

@codecov

codecov Bot commented Dec 24, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.20%. Comparing base (ddb1c93) to head (fc631ee).

Files with missing lines Patch % Lines
src/luarocks/deps.lua 50.00% 2 Missing ⚠️
src/luarocks/fs.lua 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1844      +/-   ##
==========================================
- Coverage   86.64%   85.20%   -1.44%     
==========================================
  Files          96       95       -1     
  Lines       10962    10930      -32     
==========================================
- Hits         9498     9313     -185     
- Misses       1464     1617     +153     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@catwell
catwell force-pushed the pr/lua-5.5 branch 2 times, most recently from 8828aaf to 1379f8a Compare December 24, 2025 09:35
@luau-project

Copy link
Copy Markdown
Collaborator

@catwell I am testing your changes to install LuaRocks on Windows.

To install LuaRocks through the install.bat file (considered a legacy method to install LuaRocks, but still supported), the following changes are needed:

diff --git a/install.bat b/install.bat
index 5210a862..3f679a82 100644
--- a/install.bat
+++ b/install.bat
@@ -136,7 +136,7 @@ Configuring the destinations:
                if you create a self contained installation.
                
 Configuring the Lua interpreter:
-/LV [version]  Lua version to use; either 5.1, 5.2, 5.3, or 5.4.
+/LV [version]  Lua version to use; either 5.1, 5.2, 5.3, 5.4, or 5.5.
                Default is auto-detected.
 /LUA [dir]     Location where Lua is installed - e.g. c:\lua\5.1\
                If not provided, the installer will search the system
@@ -258,8 +258,8 @@ local function check_flags()
 			die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION)
 		end
 	end
-	if not vars.LUA_VERSION:match("^5%.[1234]$") then
-		die("Bad argument: /LV must either be 5.1, 5.2, 5.3, or 5.4")
+	if not vars.LUA_VERSION:match("^5%.[12345]$") then
+		die("Bad argument: /LV must either be 5.1, 5.2, 5.3, 5.4, or 5.5")
 	end
   if USE_MSVC_MANUAL and USE_MINGW then
     die("Cannot combine option /MSVC and /MW")
@@ -277,7 +277,7 @@ local function detect_lua_version(interpreter_path)
 	local full_version = handler:read("*a")
 	handler:close()
 
-	local version = full_version:match(" (5%.[1234])$")
+	local version = full_version:match(" (5%.[12345])$")
 	if not version then
 		return nil, "unknown interpreter version '" .. full_version .. "'"
 	end
@@ -289,7 +289,7 @@ local function look_for_interpreter(directory)
 	if lua_version_set then
 		names = {S"lua$LUA_VERSION.exe", S"lua$LUA_SHORTV.exe"}
 	else
-		names = {"lua5.4.exe", "lua54.exe", "lua5.3.exe", "lua53.exe", "lua5.2.exe", "lua52.exe", "lua5.1.exe", "lua51.exe"}
+		names = {"lua5.5.exe", "lua55.exe", "lua5.4.exe", "lua54.exe", "lua5.3.exe", "lua53.exe", "lua5.2.exe", "lua52.exe", "lua5.1.exe", "lua51.exe"}
 	end
 	table.insert(names, "lua.exe")
 	table.insert(names, "luajit.exe")
@@ -1024,7 +1024,7 @@ end
 if not exec(S[[XCOPY /S src\luarocks\*.* "$LUADIR\luarocks" >NUL]]) then
 	die()
 end
-if vars.LUA_VERSION ~= "5.3" or vars.LUA_VERSION ~= "5.4" then
+if vars.LUA_VERSION ~= "5.3" or vars.LUA_VERSION ~= "5.4" or vars.LUA_VERSION ~= "5.5" then
 	-- Copy the vendored lua-copmat53 source files
 	if not exists(S[[$LUADIR\compat53]]) then
 		if not mkdir(S[[$LUADIR\compat53]]) then

Note

Without the patch above, the installation fails for the Lua 5.5 interpreter. Applying this patch, it installs nicely.

@luau-project

Copy link
Copy Markdown
Collaborator

Update

Hi guys.

In the current state of this PR branch, I identified a bug in the process to setup Lua 5.5 + LuaRocks on Windows through the legacy install.bat file, with both MSVC or MinGW-w64 toolchains.

Note

It only reproduces with Lua 5.5, not the other versions. In short, it installs fine, but it is unable to set config values

luarocks config "external_deps_dirs[2]" "C:\mingw64"

Link to the bug reproduction on CI: https://github.com/luau-project/ci-tests/actions/runs/20491907335

Expand to see the workflow
name: Test

on: push

jobs:
  install-bat-test:
    runs-on: windows-latest
    defaults:
      run:
        shell: cmd
    strategy:
      fail-fast: false
      matrix:
        lua-version:
          - 5.1
          - 5.2
          - 5.3
          - 5.4
          - 5.5
        toolchain:
          - MSVC
          - MW

    steps:
      - name: Checkout catwell branch
        uses: actions/checkout@v6
        with:
          repository: catwell/luarocks
          ref: pr/lua-5.5
          path: lr

      - name: Setup MSVC dev prompt
        if: ${{ matrix.toolchain == 'MSVC' }}
        uses: ilammy/msvc-dev-cmd@v1

      - name: Install Lua
        uses: luau-project/setup-lua@v1
        with:
          lua-version: ${{ matrix.lua-version }}
          luarocks-version: none

      - name: Install LuaRocks through install.bat
        working-directory: lr
        run: |
          .\install.bat ^
            /P ${{ github.workspace }}\.luarocks ^
            /LUA ${{ github.workspace }}\.lua ^
            /${{ matrix.toolchain }} ^
            /NOREG ^
            /NOADMIN ^
            /Q ^
            /F

      - name: Place LuaRocks on PATH environment variable
        shell: pwsh
        run: |
          Get-ChildItem "${{ github.workspace }}\.luarocks" -Recurse -File |
          Where-Object Name -EQ "luarocks.bat" |
          Select-Object -ExpandProperty FullName -First 1 |
          Split-Path |
          ForEach-Object {
            Write-Host "Adding $_ to PATH environment variable";
            Add-Content "${{ github.path }}" "$_";
          }

      - name: Set LUA_PATH environment variable on GitHub runner
        run: |
          FOR /F "tokens=* USEBACKQ" %%F IN (`luarocks path --lr-path`) DO (
            ECHO LUA_PATH=%%F>>${{ github.env }}
          )

      - name: Set LUA_CPATH environment variable on GitHub runner
        run: |
          FOR /F "tokens=* USEBACKQ" %%F IN (`luarocks path --lr-cpath`) DO (
            ECHO LUA_CPATH=%%F>>${{ github.env }}
          )

      - name: Set PATH environment variable on GitHub runner
        shell: pwsh
        run: |
          $path = & luarocks path --lr-bin;
          $pathlist = New-Object System.Collections.Generic.List[string];
          $path -split ";" | ForEach-Object {
            $pathlist.Add($_.Trim());
          }
          $pathlist.Reverse();
          $pathlist | ForEach-Object {
            Write-Host "Adding `"$_`" to the system PATH environment variable";
            Add-Content ${{ github.path }} "$_";
          }

      - name: Display LuaRocks config
        run: luarocks config

      - name: Set config entry
        run: |
          luarocks config "external_deps_dirs[2]" "C:\mingw64"

Details

Reproducing it locally, I can see that the method make_dir is not being set in the module fs, but I don't know why. I'm investigating it at the moment.

@catwell

catwell commented Dec 24, 2025 •

Copy link
Copy Markdown
Contributor Author

@luau-project errors in fs modules are annoying because they are silently caught. See this I added to prevent this for the Lua module which should never fail. To diagnose the issue, do something similar for the Windows module (but it should not be committed).

I bet there is a loop variable being modified somewhere in that module...

@luau-project

Copy link
Copy Markdown
Collaborator

Update

Hi guys.

I think I did solve the problem.

Link to my CI run on LuaRocks test suite: https://github.com/luau-project/luarocks/actions/runs/20513499575
Link to install.bat tests on my branch: https://github.com/luau-project/ci-tests/actions/runs/20513690880

Here is my patch on top of this branch:

diff --git a/binary/all_in_one b/binary/all_in_one
index 9b675eba..e3d595d7 100755
--- a/binary/all_in_one
+++ b/binary/all_in_one
@@ -69,7 +69,7 @@ local function reindent_c(input)
    local indent = 0
    local previous_is_blank = true
    for line in input:gmatch("([^\n]*)") do
-      line = line:match("^[ \t]*(.-)[ \t]*$")
+      local line = line:match("^[ \t]*(.-)[ \t]*$")
 
       local is_blank = (#line == 0)
       local do_print =
diff --git a/install.bat b/install.bat
index cfb5baa4..25fc697e 100644
--- a/install.bat
+++ b/install.bat
@@ -622,7 +622,7 @@ local function get_possible_lua_directories()
 	local directories = {}
 	for dir in path:gmatch("[^;]+") do
 		-- Remove trailing backslashes, but not from a drive letter like `C:\`.
-		dir = dir:gsub("([^:])\\+$", "%1")
+		local dir = dir:gsub("([^:])\\+$", "%1")
 		-- Remove trailing `bin` subdirectory, the searcher will check there anyway.
 		if dir:upper():match("[:\\]BIN$") then
 			dir = dir:sub(1, -5)
diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua
index 7c557113..5710c982 100644
--- a/src/luarocks/cmd/write_rockspec.lua
+++ b/src/luarocks/cmd/write_rockspec.lua
@@ -35,7 +35,7 @@ local lua_versions = {
    "5.4,5.5",
    "5.1,5.2,5.3",
    "5.2,5.3,5.4",
-   "5.3,5.4,5,5",
+   "5.3,5.4,5.5",
    "5.1,5.2,5.3,5.4",
    "5.2,5.3,5.4,5.5",
    "5.1,5.2,5.3,5.4,5.5",
diff --git a/src/luarocks/cmd/write_rockspec.tl b/src/luarocks/cmd/write_rockspec.tl
index 090eac8e..2ec4eea9 100644
--- a/src/luarocks/cmd/write_rockspec.tl
+++ b/src/luarocks/cmd/write_rockspec.tl
@@ -35,7 +35,7 @@ local lua_versions = {
    "5.4,5.5",
    "5.1,5.2,5.3",
    "5.2,5.3,5.4",
-   "5.3,5.4,5,5",
+   "5.3,5.4,5.5",
    "5.1,5.2,5.3,5.4",
    "5.2,5.3,5.4,5.5",
    "5.1,5.2,5.3,5.4,5.5",
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 3eded47a..56ccf936 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -713,8 +713,8 @@ local function lua_h_exists(d, luaver)
    if fd then
       local data = fd:read("*a")
       fd:close()
-      if major == "5" and minor == "5" then
-         if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then
+      if vers.parse_version(("%s.%s"):format(major, minor)) >= vers.parse_version("5.5") then
+         if data:match("LUA_VERSION_MINOR_N%s+" .. math.tointeger(minor)) and data:match("LUA_VERSION_MAJOR_N%s+" .. math.tointeger(major)) then
             return d ~= nil
          end
       elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then
diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl
index 85980347..ea40e1d4 100644
--- a/src/luarocks/deps.tl
+++ b/src/luarocks/deps.tl
@@ -713,8 +713,8 @@ local function lua_h_exists(d: string, luaver: string): boolean, string, string,
    if fd then
       local data = fd:read("*a")
       fd:close()
-      if major == "5" and minor == "5" then
-         if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then
+      if vers.parse_version(("%s.%s"):format(major, minor)) >= vers.parse_version("5.5") then
+         if data:match("LUA_VERSION_MINOR_N%s+" .. math.tointeger(minor)) and data:match("LUA_VERSION_MAJOR_N%s+" .. math.tointeger(major)) then
             return d ~= nil
          end
       elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then
diff --git a/src/luarocks/fs.lua b/src/luarocks/fs.lua
index e1cdcb48..8785e081 100644
--- a/src/luarocks/fs.lua
+++ b/src/luarocks/fs.lua
@@ -62,9 +62,6 @@ do
    local function load_fns(module_name, inits)
       local ok, fs_table = pcall(require, module_name)
       if not ok or not type(fs_table) == "table" then
-         if module_name == "luarocks.fs.lua" then
-            require(module_name) -- do not ignore error
-         end
          return
       end
 
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua
index 86cbb45b..f0bd60a8 100644
--- a/src/luarocks/fs/win32/tools.lua
+++ b/src/luarocks/fs/win32/tools.lua
@@ -130,6 +130,7 @@ function tools.find(at)
    local result = {}
    local pipe = io.popen(fs.command_at(at, fs.quiet_stderr(vars.FIND), true))
    for file in pipe:lines() do
+      local file = file
       -- Windows find is a bit different
       local first_two = file:sub(1,2)
       if first_two == ".\\" or first_two == "./" then file=file:sub(3) end
@@ -223,7 +224,7 @@ local function get_system_users()
    local result = {}
    local fd = assert(io.popen("wmic UserAccount get name"))
    for user in fd:lines() do
-      user = user:gsub("%s+$", "")
+      local user = user:gsub("%s+$", "")
       if not exclude[user] then
          table.insert(result, user)
       end

Main part (concise explanation)

@catwell

I bet there is a loop variable being modified somewhere in that module...

Indeed, you were right. The installation issue was triggering due control variables being changed in for-loop at src/luarocks/fs/win32/tools.lua.

First change

Based on this comment (#1812 (comment)) saying that Lua upgrades are mostly simple edits, I decided to revert your change

diff --git a/src/luarocks/fs.lua b/src/luarocks/fs.lua
index e1cdcb48..8785e081 100644
--- a/src/luarocks/fs.lua
+++ b/src/luarocks/fs.lua
@@ -62,9 +62,6 @@ do
    local function load_fns(module_name, inits)
       local ok, fs_table = pcall(require, module_name)
       if not ok or not type(fs_table) == "table" then
-         if module_name == "luarocks.fs.lua" then
-            require(module_name) -- do not ignore error
-         end
          return
       end
 

Second change

Also, I decided to improve the following part eyeing the next updates:

diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl
index 85980347..ea40e1d4 100644
--- a/src/luarocks/deps.tl
+++ b/src/luarocks/deps.tl
@@ -713,8 +713,8 @@ local function lua_h_exists(d: string, luaver: string): boolean, string, string,
    if fd then
       local data = fd:read("*a")
       fd:close()
-      if major == "5" and minor == "5" then
-         if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then
+      if vers.parse_version(("%s.%s"):format(major, minor)) >= vers.parse_version("5.5") then
+         if data:match("LUA_VERSION_MINOR_N%s+" .. math.tointeger(minor)) and data:match("LUA_VERSION_MAJOR_N%s+" .. math.tointeger(major)) then
             return d ~= nil
          end
       elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then

Extra part (optional read)

In order to find that issue, it was only possible after (hacking a way to) setting up a competent Lua debugger (https://github.com/actboy168/lua-debug). @actboy168 thank you for the Lua debugger plugin for VS code.

After the fix for the installation issue, I got so upset by this control variable issue that I decided to double-check every for-loop on LuaRocks's source code.

Tip

For those interested in the task to find for-loops that may contain attribution of variables, I used Find in files feature of VS code in the following manner:

  • I used the regex for\s+[a-zA-Z_][a-zA-Z0-9_]*\s*,\s*[a-zA-Z_][a-zA-Z0-9_]*\s+in to track loops in the form of for i, v in;
  • The regex for\s+[a-zA-Z_][a-zA-Z0-9_]*\s+in to track loops in the form of for v in.
  • The regex for\s+[a-zA-Z_][a-zA-Z0-9_]*\s*= to track numeric for-loops for i =.

All in all, these led me to analyse a few hundred for-loops.

Important

I did ask on lua-l mail list, and it is enough to check for changes in the first variable of the for-loop (often called the control variable in the manual https://www.lua.org/manual/5.5/manual.html#3.3.5)

@catwell

catwell commented Dec 26, 2025 •

Copy link
Copy Markdown
Contributor Author

@luau-project Thanks, I have integrated your changes.

Regarding the errors in fs modules being silently caught I have removed my workaround for the Lua module and opened #1849

Regarding finding the issue in the code base, this can also help (it found the Windows fs module issues), although it would not have found the one embedded in the .bat script:

for x in $(find . | grep '.lua$'); do
    lua55 "$x" 2>&1 | grep assign
done

Currently it no longer reports anything.

@daurnimator daurnimator left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me.

@daurnimator
daurnimator merged commit 6b7b6c2 into luarocks:main Dec 26, 2025
@mcepl

mcepl commented Jan 6, 2026

Copy link
Copy Markdown

I cannot find whether there is a new release planned for this. Is there?

@catwell

catwell commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

@mcepl the latest release (3.13.0) includes this but there is a problem with the rockspec (#1851)

@luau-project

Copy link
Copy Markdown
Collaborator

I cannot find whether there is a new release planned for this. Is there?

Usually, https://luarocks.org/releases/ redirects to the releases page.

@mcepl

mcepl commented Jan 7, 2026 •

Copy link
Copy Markdown

@mcepl the latest release (3.13.0) includes this but there is a problem with the rockspec (#1851)

I actually got caught by #1848 (comment) not by broken rockspec, we don’t use it in openSUSE packaging of luarocks themselves (https://src.opensuse.org/lua/lua-luarocks/src/branch/main/lua-luarocks.spec).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants