Skip to content

Instantly share code, notes, and snippets.

@yagop
Created April 5, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yagop/6a0e06d98d682ca32667 to your computer and use it in GitHub Desktop.
Save yagop/6a0e06d98d682ca32667 to your computer and use it in GitHub Desktop.
Luarocks as self-contained
#!/usr/bin/env bash
# This script installs luarocks as self-contained inside .luarocks of current dir
THIS_DIR=$(cd $(dirname $0); pwd)
git clone https://github.com/keplerproject/luarocks.git
cd luarocks
git checkout tags/v2.2.1 # Current stable
PREFIX="$THIS_DIR/.luarocks"
./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make build && make install
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
cd ..
rm -rf luarocks
# IMPORTANT!
export LUA_CPATH=";;${PREFIX}/lib/lua/5.2/?.so"
export LUA_PATH=";;${PREFIX}/share/lua/5.2/?.lua;${PREFIX}/share/lua/5.2/?/init.lua"
# Maybe you want:
# echo "export LUA_CPATH=\"$LUA_CPATH\"" >> ~/.bashrc
# echo "export LUA_PATH=\"$LUA_PATH\"" >> ~/.bashrc
# echo "export PATH=$PREFIX/bin:${PATH}" >> ~/.bashrc
# Now you can ./.luarocks/bin/luarocks whatever
# Or luarocks whatever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment