Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Cannot run on Windows, get_opts fails #7

OlivierA opened this Issue Aug 14, 2011 · 11 comments


None yet
7 participants

I'm trying to use moonscript-0.1.0-1 installed with LuaRocks on my Windows 7 computer.

"moonc" or "moon" always fail with the following error, whatever the command-line arguments are:

lua: fatal error: `C:\LuaRocks/share/lua/5.1//alt_getopt.lua:75: attempt to get length of local 'arg' (a nil value)
stack traceback:
        C:\LuaRocks/share/lua/5.1//alt_getopt.lua:75: in function 'get_ordered_opts'
        C:\LuaRocks/share/lua/5.1//alt_getopt.lua:156: in function 'get_opts'
        [string "..."]:11: in main chunk'

How do you install it? I can't even install it. I can install and run it just fine on OSX though, but not on Windows :(

Here is how I did, it requires a bit of setup: http://www.omnimaga.org/index.php?topic=9938.msg181241#msg181241

yehnan commented Aug 20, 2011

I have the same issue and don't know what to do next. Is author fixing this?
Thanks to OlivierA, your post is helpful.
By the way, is there someone trying to install MoonScript on cygwin? I can't even let LuaRocks work on cygwin.


leafo commented Aug 21, 2011

It sounds like a bug in the alt-getopt library I am using. I haven't had a chance to test on windows yet. I am in progress of settings up a windows machine for testing.

If you want any test from me just ask.

I have the same issue as the OlivierA. I am on Windows 7 64-bit and I have tried using the VS 2010 command prompt, the Cygwin bash shell, "luarocks install xxx" for all values of xxx that could possibly relate to Moonscript dependencies, uninstalling/reinstalling Lua for Windows and LuaRocks, and so on. It might be as simple as a path separator issue, I don't know. I was getting errors with "luarocks install lpeg" before I used the VS 2010 command prompt, and I still get some odd errors with moon.exe not finding packages depending on where that executable is located. I hope someone has already figured this out...
EDIT: I just needed to check out git head, rename moon and moonc to moon.lua and moonc.lua (probably unnecessary), and create .bat files to run those lua files, like so: "C:\Lua\5.1\lua.exe moon.lua %*" is contents of moon.bat , though you would need to adjust this for your install path. Since I had already managed to get the dependencies by running LuaRocks to try to install MoonScript from the VS 2010 prompt, this worked on the first try.


leafo commented Oct 2, 2011

Although not a solution to this specific problem, I do have windows binaries for moonscript now:


Included are the executables moon for and moonc, additionally I have included moonscript.dll, which is a lua module including both moonscript and lpeg, so it can be required without any additional dependencies.

The code for these is on the binaries branch: https://github.com/leafo/moonscript/tree/binaries

The binaries are using an embedded copy of alt-getopt which works fine, so I am not sure why it isn't working in the original case.

OlivierA commented Oct 2, 2011

Excellent leafo! It works well for me.

ipstone commented Jan 29, 2013

the binary works fine, but the luarocks installed version doesn't work. I explored this today, and found:

  1. using a developer console (such as visual studio express command prompt) to run luarocks, then installation can proceed with compliation etc
  2. however, even if the packages compiled while, when running moon, it gives these errors:

I am guessing it's the "" vs "/" !

I tried to install from the official luarocks,

  1. might the rock there has this flaw (with getopt line 75)?
  2. or it's the path (arg) that getopt received from others containing this?

C:\Users\teda\lua5.1>moon -h
lua: fatal error: `C:\Users\teda\lua5.1\lua/alt_getopt.lua:75: attempt to get
length of local 'arg' (a nil value)
stack traceback:
C:\Users\teda\lua5.1\lua/alt_getopt.lua:75: in function 'get_ordered_o
C:\Users\teda\lua5.1\lua/alt_getopt.lua:156: in function 'get_opts'
[string "..."]:11: in main chunk'
Content-type: text/plain

Configuration fatal error: see error log!
C:\Users\teda\lua5.1\lua/alt_getopt.lua:75: attempt to get length of local 'ar
g' (a nil value)
stack traceback:
C:\Users\teda\lua5.1\lua/alt_getopt.lua:75: in function 'get_ordered_o
C:\Users\teda\lua5.1\lua/alt_getopt.lua:156: in function 'get_opts'
[string "..."]:11: in main chunk


leafo commented Jan 29, 2013

It sounds like the script that wraps the moon executable is not sending the arguments down to my code.

I've been able to compile and run moonscript on windows with luarocks but I use the mingw backend instead of the visual studio one, I wonder if that has anything to do with it. I'll have to do some investigation.

@leafo leafo closed this Dec 28, 2015

I download the binary from the main page, but it fails. Howerver, the newest binary from @leafo works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment