On This Page
Finally I got around to trying out LuaRocks by installing it in my system and also creating a rockspec to add my simple Lua module in the LuaRocks collection. Here are some tips I picked up:
- Write the rockspec file as explained here
- Save the file with the name as lowercase package and version example many2one-22.214.171.124-3.rockspec. Here 126.96.36.199 is the version number and -3 is the rockspec number in case I just change something in the rockspec. This should match the version mentioned in the rockspec.
- Create a rock using luarocks and the rockspec described below
- Test the rock as described below
- Upload the rock and rockspec to Luarocks
here. I had my script in github. One thing I did wrong was to provide an https url for github and then luarocks gives an error in installation. I had to make the URL start with
git://that fixed it.
And it packed the files in a rock file.
NOTE: When I put the rockspec in a subdirectory like I did in tableUtils I had to run the command from the repository root directory like this:
It created a rock in the repository root. Also note in the rockspec the module file path has to be given from the repository root.
Then I simply uploaded the rockspec and rock files on LuaRocks and my 1st Lua script is available through LuaRocks!
If that works and installs the rock then you can upload the rockspec and rock file to the LuaRocks server.
This page gives the download link
Make sure MinGW is installed and is in the path of the shell from which you execute the above command.
/LV specifies my lua version
/LUA specifies my Lua root path which is the root directory path of the hierarchy I described above
/MW specifies I want to use mingw as my build system
/P specifies where I want the LuaRocks to be installed. LuaRocks creates the last directory (in the above case 'luarocks') and installs there.
/NOADMIN The installer requires admin priviledges. If not available it will elevate a new process. Use this switch to prevent elevation, but make sure the destination paths are all accessible for the current user.
Now the problem with this installation is that the rocks installed are not in my Lua Path. So I need to have package.path and package.cpath updated in my Lua executable so it points to the directory where LuaRocks installs its rocks.
At the end of the installation LuaRocks displays a list of paths that must be updated in the Lua executable and the command environment. For guidance on how to update the paths in the Lua executable directly see here. I simply took the text from the LuaRocks output and converted to a batch file which looks like this:
NOTE Here in the 1st Path statement I placed the luarocks bin path in front of all the previously defined paths so that when this batch file is run it places the lua executable in the luarocks installation 1st in line to run when lua is called from the command line.
I simply run this batch file to initialize my LuaRocks environment. I did not add them permanently since I have a separate Lua setup system which I use.
After the install process is done. It is best to run:
This package is needed for uploading rockspecs and may be used by LuaRocks at other times as well.
- Download and compile openssl. If you are not able to do that refer here for instructions and a script on how it can be done on windows
- Copy the include directory (named openssl) containing all the include files of openssl sources into the rootPath\include directory.
- Copy the generated dll files (libeay32 and ssleay32) into the rootPath\bin directory
- Copy the generated dll files (libeay32 and ssleay32) into the path of your compiler libraries. I was using MinGW so I placed them at C:\mingw\lib directory. To see which directories mingw compiler is looking at do:
- Now run:
- It should be able to install the rock now.