Skip to content

Instantly share code, notes, and snippets.

@hazzard993
Last active June 6, 2024 07:54
Show Gist options
  • Save hazzard993/0e0481d90b3a8566c1eebfc1868cab0a to your computer and use it in GitHub Desktop.
Save hazzard993/0e0481d90b3a8566c1eebfc1868cab0a to your computer and use it in GitHub Desktop.
LuaRocks installation guide for Windows 10 users

Via Windows Linux Subsystem (WSL)

The luarocks package can be installed on a Windows Linux Subsystem.

Once installed, to use it, use luarocks inside a WSL shell or wsl luarocks within a Windows shell.

wsl                             # Enter WSL shell (if installed and enabled)
sudo apt-get update             # Update package lists (otherwise luarocks may not be found)
sudo apt-get install luarocks   # Install luarocks

Limitation

Installed "rocks" will only be available within WSL, not Windows.

Due to this WSL may have issues with Windows paths. The command wsl wslpath <path> may help in select cases where a path conversion is needed.

Via Package Management Systems

Scoop

You can use scoop to install lua-for-windows which includes luarocks.

# Install Scoop (run in PowerShell)
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
# Windows Shell
scoop install lua-for-windows

Some rocks can be used within on the command line (like ldoc), they will not be within your %PATH%.

You can create a .cmd file in %USERPROFILE%\scoop\shims to work around this.

e.g.

:: Contents for "%USERPROFILE%\scoop\shims\ldoc.cmd"
@echo off
set LDOCPATH=%USERPROFILE%\scoop\apps\lua-for-windows\current\rocks\ldoc\1.4.6-2\bin\ldoc.lua
@lua "%LDOCPATH%" %*

Manual install

Refer to the offical instructions for more details.

@hubaishan
Copy link

I got
Couldn't find manifest for 'luarocks'.

@hazzard993
Copy link
Author

Looks like it is now available within lua-for-windows, try scoop install lua-for-windows (updated instructions above too).

@Ismoh
Copy link

Ismoh commented May 20, 2022

Any idea how to fix that?

~$ sudo apt-get install luarocks
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package luarocks

I fixed it this way:

sudo apt-get update
sudo apt-get install lua5.1

I am using lua 5.1

@hazzard993
Copy link
Author

Ah yes I should've mentioned an sudo apt-get update may be needed. Added this to instructions

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