Windows support
Installs from the LuaRocks source package on Unix and uses the precompiled binaries on Windows.
CI: Test matrix runs it with Lua 5.1 (oldest supported), 5.4 (newest supported) and LuaJIT; being based on gh-actions-lua, it uses MSVC for PUC-Rio Lua runs and Mingw for the LuaJIT run. In principle this action should work with any combination of Lua version and supported Windows compiler, even though gh-actions-lua currently doesn't (it would be rather annoying to support the full Windows matrix on gh-actions-lua because the LuaJIT Makefile works out of the box with Mingw and my handwritten implementation for building PUC Lua targets MSVC and would have to be rewritten for Mingw).
Closes #13.
Any progress here?
@leafo You can see it running on my fork's CI here: https://github.com/hishamhm/gh-actions-luarocks/actions/runs/2758104388
So this PR could be merged?
Up — can this be merged? Seems like it should address https://github.com/leafo/gh-actions-luarocks/issues/17 and I'd need that.
Up?
@hishamhm Could you make a release on your fork? Then we could simply use your version for the moment.
@hishamhm , trying your fork off the tip of master. Upon attempting to install packages via Luarocks on windows-latest using the default Win shell, I'm getting luarocks: command not found. Any advice? I'm using luarocksVersion: "3.11.0" as you recommended above, and all the other actions used are pointing to the latest release at the time of writing.
Edit: fixed by moving the Lua/Luarocks install steps after a repo checkout.
@magneto538 no idea, sorry! it seems to be working for others, so I don't even know what to suggest...
Great work on the windows support and thank you for your fork @hishamhm - everything seems to work perfectly except when I try to require luarocks.loader, which can't be found unfortunately... This only happens for Windows.
Here is my workflow:
on:
workflow_dispatch:
jobs:
test-luarocks-loader:
name: Test LuaRocks Loader
runs-on: windows-latest
steps:
- name: Setup Microsoft Visual C++ Developer Command Prompt
uses: ilammy/[email protected]
- name: Setup Lua
uses: leafo/[email protected]
- name: Setup LuaRocks
uses: hishamhm/gh-actions-luarocks@master
with:
luarocksVersion: 3.11.0
- name: Test require luarocks loader
run: lua -e "require('luarocks.loader');"
And here is the output of the last step above:
2024-04-06T06:47:45.9623061Z D:/a/lua-fenster/lua-fenster/.lua/bin\lua.exe: (command line):1: module 'luarocks.loader' not found:
2024-04-06T06:47:45.9624644Z no field package.preload['luarocks.loader']
2024-04-06T06:47:45.9626041Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\lua\luarocks\loader.lua'
2024-04-06T06:47:45.9627431Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\lua\luarocks\loader\init.lua'
2024-04-06T06:47:45.9629064Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\luarocks\loader.lua'
2024-04-06T06:47:45.9631579Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\luarocks\loader\init.lua'
2024-04-06T06:47:45.9633156Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\..\share\lua\5.4\luarocks\loader.lua'
2024-04-06T06:47:45.9634704Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\..\share\lua\5.4\luarocks\loader\init.lua'
2024-04-06T06:47:45.9636184Z no file '.\luarocks\loader.lua'
2024-04-06T06:47:45.9637341Z no file '.\luarocks\loader\init.lua'
2024-04-06T06:47:45.9638632Z no file 'C:\Users\runneradmin\AppData\Roaming/luarocks/share/lua/5.4/luarocks\loader.lua'
2024-04-06T06:47:45.9640845Z no file 'C:\Users\runneradmin\AppData\Roaming/luarocks/share/lua/5.4/luarocks\loader/init.lua'
2024-04-06T06:47:45.9642556Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\luarocks\loader.dll'
2024-04-06T06:47:45.9644015Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\..\lib\lua\5.4\luarocks\loader.dll'
2024-04-06T06:47:45.9645342Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\loadall.dll'
2024-04-06T06:47:45.9646255Z no file '.\luarocks\loader.dll'
2024-04-06T06:47:45.9647493Z no file 'C:\Users\runneradmin\AppData\Roaming/luarocks/lib/lua/5.4/luarocks\loader.dll'
2024-04-06T06:47:45.9648931Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\luarocks.dll'
2024-04-06T06:47:45.9650260Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\..\lib\lua\5.4\luarocks.dll'
2024-04-06T06:47:45.9651596Z no file 'D:\a\lua-fenster\lua-fenster\.lua\bin\loadall.dll'
2024-04-06T06:47:45.9652592Z no file '.\luarocks.dll'
2024-04-06T06:47:45.9657461Z no file 'C:\Users\runneradmin\AppData\Roaming/luarocks/lib/lua/5.4/luarocks.dll'
2024-04-06T06:47:45.9682363Z stack traceback:
2024-04-06T06:47:45.9719912Z [C]: in function 'require'
2024-04-06T06:47:45.9743053Z (command line):1: in main chunk
2024-04-06T06:47:45.9771143Z [C]: in ?
I'm not really using the luarocks loader so it's not a critical issue, just noticed it and wanted to let you know.
EDIT:
Okay I just noticed that requiring my own library after running luarocks build also doesn't seem to work... There is definitely something missing or using the wrong path.
I did not try it, but I assume installing something with luarocks install <rock> and then requiring the installed rock will also not work :/
EDIT 2:
Seems like I have found another issue. When running luarocks build with LuaJIT on Windows it can't find the Lua library. This only happens when I set luaVersion to luajit in leafo/gh-actions-lua, but works for 5.1, 5.2, 5.3, 5.4 and Linux.
There are two different outputs with the same meaning, depending on whether I already ran luarocks/luarocks config once before:
Error: Build error: Failed finding the Lua library. You can use `luarocks config variables.LUA_LIBDIR <path>` to set the correct location.
testlib dev-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)
or:
Error: Failed finding Lua library. You may need to configure LUA_LIBDIR.
This could very likely be an issue with leafo/gh-actions-lua and not with your fork, but I'll let you know anyway.
I have a problem related to packages not found too. My workflow requires the lfs Lua module. When attempting to run a script that requires the lfs module after having installed it, I'm getting The specified module could not be found, as per log attached. Any advice?
name: foo
on:
workflow_dispatch:
jobs:
tests:
runs-on: windows-latest
steps:
- uses: actions/[email protected]
- name: Setup Microsoft Visual C++ Developer Command Prompt
uses: ilammy/[email protected]
- name: Setup Lua
uses: leafo/[email protected]
- name: Setup LuaRocks
uses: hishamhm/gh-actions-luarocks@master
with:
luarocksVersion: 3.11.0
- name: Environment setup
run: |
luarocks install luacheck
luacheck --version
luarocks install busted
luarocks install luafilesystem
luarocks install serpent
lua runScript.lua ## this script requires luafilesystem (lfs)
Log from Environment setup step:
lfs.c
Microsoft (R) Incremental Linker Version 14.38.33135.0
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library C:\Users\RUNNER~1\AppData\Local\Temp\luarocks_build-LuaFileSystem-1.8.0-1-8365456\lfs.lib and object C:\Users\RUNNER~1\AppData\Local\Temp\luarocks_build-LuaFileSystem-1.8.0-1-8365456\lfs.exp
No existing manifest. Attempting to rebuild...
Installing https://luarocks.org/luacheck-1.1.2-1.src.rock
Missing dependencies for luacheck 1.1.2-1:
argparse >= 0.6.0 (not installed)
luafilesystem >= 1.6.3 (not installed)
luacheck 1.1.2-1 depends on lua >= 5.1 (5.4-1 provided by VM: success)
luacheck 1.1.2-1 depends on argparse >= 0.6.0 (not installed)
Installing https://luarocks.org/argparse-0.7.1-1.src.rock
argparse 0.7.1-1 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM: success)
argparse 0.7.1-1 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT)
luacheck 1.1.2-1 depends on luafilesystem >= 1.6.3 (not installed)
Installing https://luarocks.org/luafilesystem-1.8.0-1.src.rock
luafilesystem 1.8.0-1 depends on lua >= 5.1 (5.4-1 provided by VM: success)
cl /nologo /MD /O2 -c -Fosrc/lfs.obj -ID:/a/myrepo/myrepo/.lua/include src/lfs.c
link -dll -def:lfs.def -out:C:\Users\RUNNER~1\AppData\Local\Temp\luarocks_build-LuaFileSystem-1.8.0-1-8365456\lfs.dll D:\a\myrepo\myrepo\.lua\lib\lua54.lib src/lfs.obj
luafilesystem 1.8.0-1 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT/X11)
luacheck 1.1.2-1 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT)
D:\a\myrepo\myrepo\.lua\bin\lua.exe: error loading module 'lfs' from file 'C:\Users\runneradmin\AppData\Roaming\luarocks\lib\lua\5.4\lfs.dll':
The specified module could not be found.
stack traceback:
[C]: in ?
[C]: in function 'require'
...n\AppData\Roaming\luarocks\share\lua\5.4\luacheck\fs.lua:3: in main chunk
[C]: in function 'require'
...ppData\Roaming\luarocks\share\lua\5.4\luacheck\cache.lua:1: in main chunk
[C]: in function 'require'
...AppData\Roaming\luarocks\share\lua\5.4\luacheck\main.lua:2: in main chunk
[C]: in function 'require'
...cks\lib\luarocks\rocks-5.4\luacheck\1.1.2-1\bin\luacheck:2: in main chunk
[C]: in ?
core.c
compat.c
time.c
environment.c
random.c
link -dll -def:core.def -out:C:\Users\RUNNER~1\AppData\Local\Temp\luarocks_build-lua-term-0.8-1-[62](https://github.com/<hidden>)
lua-term 0.8-1 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT/X11)
busted 2.2.0-1 depends on penlight >= 1.3.2 (not installed)
Installing https://luarocks.org/penlight-1.13.1-1.src.rock
penlight 1.13.1-1 depends on luafilesystem (1.8.0-1 installed: success)
penlight 1.13.1-1 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT/X11)
busted 2.2.0-1 depends on mediator_lua >= 1.1.1 (not installed)
Installing https://luarocks.org/mediator_lua-1.1.2-0.rockspec
mediator_lua 1.1.2-0 depends on lua >= 5.1 (5.4-1 provided by VM: success)
mediator_lua 1.1.2-0 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT <http://opensource.org/licenses/MIT>)
busted 2.2.0-1 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT <http://opensource.org/licenses/MIT>)
Installing https://luarocks.org/luafilesystem-1.8.0-1.src.rock
luafilesystem 1.8.0-1 is already installed in C:\Users\runneradmin\AppData\Roaming\luarocks
Use --force to reinstall.
Cloning into 'serpent'...
Note: switching to 'd78[68](https://github.com/<hidden>)
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to eate a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
Installing https://luarocks.org/serpent-0.30-2.rockspec
D:/a/myrepo/myrepo/.lua/bin\lua.exe: error loading module 'lfs' from file 'C:\Users\runneradmin\AppData\Roaming\luarocks\lib\lua\5.4\lfs.dll':
The specified module could not be found.
stack traceback:
[C]: in ?
[C]: in function 'require'
ActionsHelpers/myrepo.lua:8: in main chunk
[C]: in ?
serpent 0.30-2 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM: success)
serpent 0.30-2 is now installed in C:\Users\runneradmin\AppData\Roaming\luarocks (license: MIT)
@magneto538 are you using @hishamhm s fork? That should fix that issue (see https://github.com/lunarmodules/luasystem/pull/17#issuecomment-1979530101) unless you're hitting a new issue.
@Tieske Yes, I am, as per the code snippet I've posted.
Luarocks config output for completeness:
Configuration:
Lua:
Version : 5.4
LUA : D:/a/myrepo/myrepo/.lua\bin\lua.exe (ok)
LUA_INCDIR : D:/a/myrepo/myrepo/.lua/include (ok)
LUA_LIBDIR : D:\a\myrepo\myrepo\.lua\lib (ok)
Configuration files:
System : C:\Program Files\luarocks\config-5.4.lua (not found)
User : C:\Users\runneradmin\AppData\Roaming\luarocks\config-5.4.lua
(ok)
Rocks trees in use:
C:\Users\runneradmin\AppData\Roaming\luarocks ("user")
@hishamhm bump in case you missed it ^
@magneto538 as a workaround, try adding luarocks config fs_use_modules false before luarocks install luafilesystem
@hishamhm thanks. Now lfs would install correctly as per Luarocks' output, however it still fails when called from a script executed after setting up the environment (see the first snippet in this comment for reference):
D:/a/myrepo/myrepo/.lua/bin\lua.exe: runScript.lua:8: module 'lfs' not found:
no field package.preload['lfs']
no file 'D:\a\myrepo\myrepo\.lua\bin\lua\lfs.lua'
no file 'D:\a\myrepo\myrepo\.lua\bin\lua\lfs\init.lua'
no file 'D:\a\myrepo\myrepo\.lua\bin\lfs.lua'
no file 'D:\a\myrepo\myrepo\.lua\bin\lfs\init.lua'
no file 'D:\a\myrepo\myrepo\.lua\bin\..\share\lua\5.4\lfs.lua'
no file 'D:\a\myrepo\myrepo\.lua\bin\..\share\lua\5.4\lfs\init.lua'
no file '.\lfs.lua'
no file '.\lfs\init.lua'
no file 'C:\Users\runneradmin\AppData\Roaming\luarocks\share\lua\5.4\lfs.lua'
no file 'C:\Users\runneradmin\AppData\Roaming\luarocks\share\lua\5.4\lfs\init.lua'
no file 'D:\a\myrepo\myrepo\.lua\bin\lfs.dll'
no file 'D:\a\myrepo\myrepo\.lua\bin\..\lib\lua\5.4\lfs.dll'
no file 'D:\a\myrepo\myrepo\.lua\bin\loadall.dll'
no file '.\lfs.dll'
no file 'C:\Users\runneradmin\AppData\Roaming\luarocks\lib\lua\5.4\lfs.dll'
stack traceback:
[C]: in function 'require'
runScript.lua:8: in main chunk
[C]: in ?
@magneto538 Add eval $(luarocks path) before the lua call?
@hishamhm no luck with that one:
eval: D:\a\_temp\019bc3a1-dc0e-4b98-879f-3321a897784e.ps1:8
Line |
8 | eval $(luarocks path)
| ~~~~
| The term 'eval' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the
| spelling of the name, or if a path was included, verify that the path is correct and try again.
@magneto538 he mistakenly gave you the code for Unix, here's how you do it on Windows CMD:
luarocks path > "%temp%\_lrp.bat"
call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"
(You can find this command by running luarocks path --help)
You might have to set shell: cmd in your GitHub Actions job to use CMD instead of the default PowerShell.
Unfortunately I already tried this without success, but you might be luckier 🤞🏻
EDIT
I have started investigating my issue again and I'm pretty sure that the problem lies within my C module. Maybe I'm not exporting correctly or something is wrong with the .dll file, but everything suggests that Lua CAN find the module file, but CAN'T find the module itself in the file.
Super hard to debug though... Guess I'll have to spin up a VM.
EDIT 2
The Windows build works in my VM, works when I download it from GitHub Actions, and works on my old Windows PC. It just doesn't work on the GitHub Actions Runner itself, which is a Window Server 2022... No idea. But probably not a bug in hishamhm's fork.
@jonasgeiler thanks! Actually I did try switching to bash before posting (while keeping the Unix eval call provided by @hishamhm) and got the exact same output I'm getting with PowerShell using your Windows command instead:
Error: Failed installing dependency: https://luarocks.org/luafilesystem-1.8.0-1.src.rock - Build error: Failed compiling module lfs.dll
argparse >= 0.6.0 (not installed)
luafilesystem >= 1.6.3 (not installed)
So nope, not working for me either.
@magneto538 GHA defaults to PowerShell as the shell, but you can set it up to switch to cmd iirc. Try adding shell: cmd.
@jonasgeiler I originally also thought the dll was wrong, hence we added this: https://github.com/lunarmodules/luasystem/pull/17/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721R66 turned out dll was fine in my case. Maybe the code can help you debug your problem.
@Tieske , I had already tried both PowerShell and cmd to no avail. I reckon I hadn't posted the cmd output here, so here we go:
LFS still isn't being picked up inside the Lua script I'm running.
- name: Setup
shell: cmd
run: |
luarocks
luarocks config fs_use_modules false
luarocks install luacheck
luarocks install busted
luarocks install luafilesystem
luarocks install serpent
luarocks path > "%temp%\_lrp.bat"
call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat"
lua myScript.lua
The above fails when executing myScript.lua, which requires lfs. The installation steps are all successful, but lfs can't be run from that script:
lua: myScript.lua:8: module 'lfs' not found:
no field package.preload['lfs']
no file 'D:\a\myRepo\myRepo\.luarocks\bin\lua\lfs.lua'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\lua\lfs\init.lua'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\lfs.lua'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\lfs\init.lua'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\..\share\lua\5.4\lfs.lua'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\..\share\lua\5.4\lfs\init.lua'
no file '.\lfs.lua'
no file '.\lfs\init.lua'
no file 'C:\Users\runneradmin\AppData\Roaming\luarocks\share\lua\5.4\lfs.lua'
no file 'C:\Users\runneradmin\AppData\Roaming\luarocks\share\lua\5.4\lfs\init.lua'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\lfs.dll'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\..\lib\lua\5.4\lfs.dll'
no file 'D:\a\myRepo\myRepo\.luarocks\bin\loadall.dll'
no file '.\lfs.dll'
no file 'C:\Users\runneradmin\AppData\Roaming\luarocks\lib\lua\5.4\lfs.dll'
stack traceback:
[C]: in function 'require'
myScript.lua:8: in main chunk
[C]: in ?
@Tieske wrote: (at)jonasgeiler I originally also thought the dll was wrong, hence we added this: https://github.com/lunarmodules/luasystem/pull/17/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721R66 turned out dll was fine in my case. Maybe the code can help you debug your problem.
Thank you for showing me the workflow you use for luasystem! I tried adapting some of your steps and I got the whole thing working once I switched to hishamhm/gh-actions-lua@master instead of leafo/[email protected] 🤔 Seems there are some flaws with leafo's Lua action aswell...
Here is the commit that finally fixed my problem: https://github.com/jonasgeiler/lua-fenster/commit/5f41f11dd87cf7843117a7d8a786d1fb17baa487
Unfortunately I didn't get LuaJIT tests to work on Windows but as long as all the other versions work I think it's fine for now.
Unfortunately I didn't get LuaJIT tests to work on Windows but as long as all the other versions work I think it's fine for now.
The trick in luasystem is that PuC Lua and LuaJIT are build using different toolchains. One uses MinGW, the other MSVC. So might be worthwhile to try and get it to work, as it provides better test coverage.
@Tieske wrote: The trick in
luasystemis that PuC Lua and LuaJIT are build using different toolchains. One uses MinGW, the other MSVC. So might be worthwhile to try and get it to work, as it provides better test coverage.
Yeah I did try to skip the MSVC step and force MingW with shell: bash and everything, just like luasystem does, but to no success... I might have missed something though and will probably revisit this problem in the future when my library gains more popularity. I could confirm that it works on LuaJIT on Windows by building it manually, so it's not a big problem.
Thanks anyways!
@hishamhm It seems like you've commited the node_modules folder here... The node_modules folder should definitely stay out of VCS.
Edit: Wait leafo also added the node_modules folder? Why?