Luarocks support


#1

Hey, I’m really curious about glitch and would love to share some of my projects with the community here. I have seen that there is a lua interpreter (Lua 5.2) installed in the base image, is there any chance of getting luarocks installed as well?
luarocks is the package manager for Lua and should allow installing other tooling such as the MoonScript language.


#2

Howdy @s-ol! We’re super happy to see folks so excited about and testing the limits of Glitch; thanks for pushing the boundaries!

Right now we’re pretty focussed on making Node.js work as well as possible and don’t expect to be adding extensive built-in support for other environments in the near future, so I wouldn’t plan on luarocks being available in the base image soon. I’m checking out what the problems are with getting it running manually and will report back with what I find.


#3

Thank you! I totally understand the choice of focusing on node and I would be very happy to use glitch without any editor or other first-class support for Lua or Moonscript anyway.

EDIT: I hadn’t realized that the base image contains a full C toolchain. That is mostly the only requirement of luarocks. What is still missing are the lua headers (seems that would be liblua52-dev), but knowing this I might be able to do a test run by compiling both Lua and Luarocks from source. I will report back here if I get anywhere as well :slight_smile:


#4

Okay, all of this totally works :slight_smile:!

I put everything in /app/PREFIX and built lua5.3 from source. The sequence of commands is as follows:

# create a user-writeable prefix
mkdir PREFIX
MPREFIX=/app/PREFIX
export PATH="$MPREFIX/bin:$PATH"

# build and install lua to $MPREFIX
wget https://www.lua.org/ftp/lua-5.3.5.tar.gz
tar xzf lua-5.3.5.tar.gz
cd lua-5.3.5
make linux
make install INSTALL_TOP=$MPREFIX

# bootstrap luarocks in $MPREFIX
wget http://luarocks.github.io/luarocks/releases/luarocks-3.0.4.tar.gz
tar xzf luarocks-3.0.4.tar.gz
cd luarocks-3.0.4
./configure --prefix=$MPREFIX --with-lua=$MPREFIX
make bootstrap

# install moonscript
eval $(luarocks path --bin)
luarocks install moonscript

# build and install tup to $MPREFIX
# (tup is my usual build system, but without fuse support it is a bit limited.
# that's probably fine)
wget http://gittup.org/tup/releases/tup-v0.7.8.tar.gz
tar xzf tup-v0.7.8.tar.gz 
cd tup-v0.7.8
TUP_SERVER=ldpreload ./build.sh
cp build/tup $MPREFIX/bin

#5

That’s great @s-ol!

I came up with more or less the same solution. https://glitch.com/edit/#!/luarocks is a project that will install lua and luarocks on remix. In order to make sure that remixes are clean (i.e. that they don’t carry along any installed rocks, for instance) I placed everything inside /app/.data, and I put the requisite commands in init.sh and used package.json to run that script on startup - if /app/.data/luarocks already exists then the script is a noop.

Feel free to do with it what you will - your solution seems like it’ll work just fine for your needs!


#6

that’s great, thank you! Exactly the solution I would have loved to do, but lacked the glitch-kung-fu to build myself (as of yet :stuck_out_tongue:)

EDIT: hold up - i can’t see the ‘luarocks’ app you linked above though, it says it might have been removed or renamed?