Neopallium/lua-zmq — Issue #22: attempt to index global index 'zmq' (a nil value)
Author: dustingooding
Created: 2012-02-03 19:40:53+00:00
State: open

I'm trying to use your Lua bindings for ZMQ, but am not having much luck.

I'm running Ubuntu 11.10 (up to date). I installed ZMQ from the Ubuntu package (`sudo apt-get install libzmq-dev libzmq1`). Then I used the instructions here to install lua-zmq using CMake (as I didn't have luarocks installed, yet). I didn't see any errors during the install.

I copy-pasted an example from zeromq.org (http://zguide.zeromq.org/lua:interrupt) but it fails to execute. The example, as written, gives the following output:

```
$ lua -i interruptTest.lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
lua: interruptTest.lua:7: module 'zhelpers' not found:
no field package.preload['zhelpers']
no file './zhelpers.lua'
no file '/usr/local/share/lua/5.1/zhelpers.lua'
no file '/usr/local/share/lua/5.1/zhelpers/init.lua'
no file '/usr/local/lib/lua/5.1/zhelpers.lua'
no file '/usr/local/lib/lua/5.1/zhelpers/init.lua'
no file '/usr/share/lua/5.1/zhelpers.lua'
no file '/usr/share/lua/5.1/zhelpers/init.lua'
no file '/opt/ros/electric/stacks/orocos_toolchain/ocl/lua/modules/zhelpers.lua'
no file './zhelpers.so'
no file '/usr/local/lib/lua/5.1/zhelpers.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/zhelpers.so'
no file '/usr/lib/lua/5.1/zhelpers.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
interruptTest.lua:7: in main chunk
[C]: ?
```

Sure enough, "zhelpers.h" is nowhere to be found on my machine. I don't blame lua-zmq for this. So, I comment out the `require"zhelpers"` line and run again.

```
$ lua -i interruptTest.lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
lua: interruptTest.lua:9: attempt to index global 'zmq' (a nil value)
stack traceback:
interruptTest.lua:9: in main chunk
[C]: ?
```

This, I believe is a problem. Lua had no problem with `require"zmq"`, but it did when I attempt to use zmq functionality. What am I missing?

For completeness, I installed the Ubuntu package for Lua's Python bindings (sudo apt-get install python-zmq) and attempted running the companion example (http://zguide.zeromq.org/py:interrupt), and I had no trouble. So, this tells me ZMQ is installed correctly and bindings work.

I went to reinstall lua-zmq using Ubuntu's package for luarocks (`sudo apt-get install luarocks`). I used the first instruction (`sudo luarocks install https://github.com/Neopallium/lua-zmq/raw/master/rockspecs/lua-zmq-scm-1.rockspec`), but because I'm behind a firewall, I'm unable to use the git:// protocol to access github.com. So, I just downloaded the rockspec, changed the url line:

```
package = "lua-zmq"
version = "scm-1"
source = {
url = "https://github.com/Neopallium/lua-zmq.git",
}
...

But, even that fails.

```
$ sudo luarocks install lua-zmq-scm-1.rockspec

Error: Error fetching file: Failed downloading https://github.com/Neopallium/lua-zmq.git
```

I really would like to use your software, but I'm just having the worst luck. Any help?
```