lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Quoting Peter Melnichenko (2016-05-25 15:03:58)
> On Mon, May 23, 2016 at 12:02 AM, Dhaval Kapil <me@dhavalkapil.com> wrote:
> > Recently, I was working in lua and needed to switch between different
> > versions frequently. This caused me various issues, like reinstalling
> > versions of lua, reinstalling luarocks to with the new lua versions, etc. I
> > even messed up with my installation somehow. To help deal with these
> > problems and being inspired by the usefulness of 'nvm'(Node Version Manager)
> > and 'rvm'(Ruby Version Manager) I decided to develop 'luavm'.
> 
> This looks great! Unfortunately it doesn't set LUA_PATH and LUA_CPATH
> and it also doesn't add directory where LuaRocks puts scripts to PATH,
> but that can be fixed by running 'eval `luarocks path --bin`' after switching to
> a new environment.
> 
> hererocks (https://github.com/mpeterv/hererocks) was mentioned here
> but it's not really a version manager, more of an installation script that
> takes care of environment isolation. Personally I use it to install various
> version combination into ~/lua51, ~/lj2, ~/lua53-nocompat, etc, then
> add a default
> like ~/lua53/bin to PATH in .bashrc and use other environments directly
> when I need to, e.g. run ~/lua51/bin/lua or ~/lj2/bin/busted.
> 
> Perhaps luavm could use hererocks for build step to avoid having
> to run 'eval `luarocks path --bin`' and to exploit some of its options,
> like choosing compat flags, building without readline, etc.

Something that I always wanted was something for Lua+LuaRocks which would be
the equivalent of virtualenv (for Python+Pip): using the Lua binaries and
library installed by the system package manager, and bootstrapping LuaRocks
into a separate directory, and then providing a way to “activate” one of
these separate directories (= environments).

A couple of months ago I decided to bite the bullet and implement RockZ [1],
which is a plugin for Zsh which allows to do things like:

  # Only needed once, for configuration

  % rockz profile default --lua=/usr/bin/lua \
                          --include=/usr/include \
                          --library=/usr/lib/liblua.so

  # Bootstraps a LuaRocks environment named “myproject” (into the
  # ~/.rockenvs/myproject directory) and activates it. LuaRocks will
  # install and manage packages inside the environment directory.

  % rockz new myproject
  % luarocks install busted
  % which lua luarocks
  /home/aperez/.rockenvs/myproject/bin/lua
  /home/aperez/.rockenvs/myproject/bin/luarocks
  % rockz deactivate  # Go back to the system-wide Lua+LuaRocks

  # Later on...

  % rockz activate    # Sets $PATH, $LUA_PATH, and $LUA_CPATH

Probably I should cut a release soon and send a proper announcement post to
the list... Also if there are enough people interested into a version that
works with Bash, it should be easy to port it (though I do not use Bash
myself much anymore, I could event try and help with it :P).

Cheers,

--
 ☛ Adrián

[1] https://github.com/aperezdc/rockz

Attachment: signature.asc
Description: signature