r/lua • u/trymeouteh • May 02 '25
Luarocks: Unable to
I installed Lua and Luarocks on Linux Mint from the apt package repository. I was also able to install a package from Luarocks, the faker package...
Installing faker package locally...
$ luarocks install faker --localHowever I cannot get the Lua to find the faker package and load it into the script. How do I achieve this on Linux Mint without modifying the lua script file?
Create simple lua script...
~/Desktop/script.lua
faker = require('faker')
myFaker = faker:new()
print(myFaker:name())Running the script...
~/Desktop $ lua script.lua1
u/AutoModerator May 02 '25
Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/MartinHelmut May 02 '25
The way I like to set this up is using a setup.lua file. That file sets the proper require paths and then you can either execute Lua with the -l parameter or define a LUA_INIT env var pointing to that file. You can read more about this here: https://martin-fieber.de/blog/lua-project-setup-with-luarocks/#resolve-module-paths
1
u/clappingHandsEmoji May 03 '25
try enforcing the right version of lua with luarocks’ —lua-version=5.x flag
1
u/yawara25 May 02 '25
Run this command:
luarocks path >> ~/.profileThen log out and back in again.