Repository navigation
support Lua 5.5 - #1844
support Lua 5.5#1844
Conversation
|
now, we need a |
|
On Debian stable, I did test your changes quickly on a few packages building them from source (
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. |
|
FYI 5.5 is out |
|
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
8828aaf to
1379f8a
Compare
|
@catwell I am testing your changes to install LuaRocks on Windows. To install LuaRocks through the 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]]) thenNote Without the patch above, the installation fails for the Lua 5.5 interpreter. Applying this patch, it installs nicely. |
UpdateHi 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 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
Link to the bug reproduction on CI: https://github.com/luau-project/ci-tests/actions/runs/20491907335 Expand to see the workflowname: 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"DetailsReproducing it locally, I can see that the method |
|
@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... |
UpdateHi 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 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)
endMain part (concise explanation)
Indeed, you were right. The installation issue was triggering due control variables being changed in for-loop at First changeBased 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 changeAlso, 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:
All in all, these led me to analyse a few hundred for-loops. Important I did ask on |
Support Lua 5.4 and 5.5, see luarocks#1832
Co-authored-by: luau-project <[email protected]>
Co-authored-by: luau-project <[email protected]>
|
@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 for x in $(find . | grep '.lua$'); do
lua55 "$x" 2>&1 | grep assign
doneCurrently it no longer reports anything. |
daurnimator
left a comment
There was a problem hiding this comment.
This looks reasonable to me.
|
I cannot find whether there is a new release planned for this. Is there? |
Usually, https://luarocks.org/releases/ redirects to the releases page. |
I actually got caught by #1848 (comment) not by broken |
This PR adds initial support for Lua 5.5. With those changes I could build LuaRocks on lua-5.5.0-rc2.