luarocks config problem on Windows

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

luarocks config problem on Windows

彭 书呆
Hi list,

I am trying to install luarocks on my Windows 10 system. luarocks installed just fine,
but I encounter some config problems. I use mingw toolchain. when I try to build the
luafilesystem rock, I got the error

 >
 > C:\Users\nerditation>luarocks install luafilesystem
 > Installing https://luarocks.org/luafilesystem-1.6.3-1.src.rock...
 > Using https://luarocks.org/luafilesystem-1.6.3-1.src.rock... switching to 'build' mode
 > mingw32-gcc -O2 -c -o src/lfs.o -Id:/Applications/lua/luadist/include/ src/lfs.c
 > 'mingw32-gcc' is not recognized as an internal or external command,
 > operable program or batch file
 >
 > Error: Build error: Failed compiling object src/lfs.o
 >

since I use the Twilight Dragon Media MinGW_w64 distribution, a.k.a. tdm-gcc, there is
no 'mingw32-gcc.exe' but 'x86_64-w64-mingw32-gcc.exe' instead, and of course the 'gcc.exe'.

I edited the 'config-5.2.lua' file of luarocks to add the following variables:

 > --[[...]]
 > variables = {
 >     MSVCRT = 'm',   -- make MinGW use MSVCRT.DLL as runtime
 >     LUALIB = 'liblua.dll.a'
 >     CC = 'gcc',
 >     LD = 'gcc',
 > }
 >--[[...]]

but luarocks won't see it and still tried to call mingw32-gcc, and link against lua5.2.lib.

I can work around it by modify luarocks/cfg.lua and change the default value of those variables,
but I wonder whether it is a bug of luarocks, or I am missing something?

b.t.w. the version is luarocks 2.2.3


thanks.

--
the nerdy Peng / 书呆彭 / Sent from Thunderbird



Reply | Threaded
Open this post in threaded view
|

RE: luarocks config problem on Windows

Thijs Schreijer
Could you please retry this with the 2.3RC1 version? some changes have been made with the configuration files.



________________________________________
From: [hidden email] [[hidden email]] on behalf of 书呆彭, Peng Yi [[hidden email]]
Sent: 24 December 2015 16:57
To: Lua mailing list
Subject: luarocks config problem on Windows

Hi list,

I am trying to install luarocks on my Windows 10 system. luarocks installed just fine,
but I encounter some config problems. I use mingw toolchain. when I try to build the
luafilesystem rock, I got the error

 >
 > C:\Users\nerditation>luarocks install luafilesystem
 > Installing https://luarocks.org/luafilesystem-1.6.3-1.src.rock...
 > Using https://luarocks.org/luafilesystem-1.6.3-1.src.rock... switching to 'build' mode
 > mingw32-gcc -O2 -c -o src/lfs.o -Id:/Applications/lua/luadist/include/ src/lfs.c
 > 'mingw32-gcc' is not recognized as an internal or external command,
 > operable program or batch file
 >
 > Error: Build error: Failed compiling object src/lfs.o
 >

since I use the Twilight Dragon Media MinGW_w64 distribution, a.k.a. tdm-gcc, there is
no 'mingw32-gcc.exe' but 'x86_64-w64-mingw32-gcc.exe' instead, and of course the 'gcc.exe'.

I edited the 'config-5.2.lua' file of luarocks to add the following variables:

 > --[[...]]
 > variables = {
 >     MSVCRT = 'm',   -- make MinGW use MSVCRT.DLL as runtime
 >     LUALIB = 'liblua.dll.a'
 >     CC = 'gcc',
 >     LD = 'gcc',
 > }
 >--[[...]]

but luarocks won't see it and still tried to call mingw32-gcc, and link against lua5.2.lib.

I can work around it by modify luarocks/cfg.lua and change the default value of those variables,
but I wonder whether it is a bug of luarocks, or I am missing something?

b.t.w. the version is luarocks 2.2.3


thanks.

--
the nerdy Peng / 书呆彭 / Sent from Thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: luarocks config problem on Windows

彭 书呆
在 2015/12/25 6:51, Thijs Schreijer 写道:
> Could you please retry this with the 2.3RC1 version? some changes have been made with the configuration files.
>

they all behave the same among version 2.3.0-rc1, 2.2.3-rc2, 2.2.0. they use the default.

actually if I place a configuration file at %appdata%\luarocks\config-5.2.lua then luarocks
will use it, but luarocks always ignores the one at D:\Applications\luarocks\config-5.2.lua,
which is generated automatically by the install.bat script; it is just not loaded at all!

this is quite counter-intuitive to me. I supposed the one in the luarocks installation
directory should be used when there doesn't exist a user special configuration file. but
this is not true at least in my situation, even if I gave the /SELFCONTAINED command line
option to the install.bat script.

I wonder whether this is a Windows specific behavior, please?

--
the nerdy Peng / 书呆彭 / Sent from Thunderbird



Reply | Threaded
Open this post in threaded view
|

Re: luarocks config problem on Windows

彭 书呆
在 2015/12/25 10:47, 书呆彭, Peng Yi 写道:
> 在 2015/12/25 6:51, Thijs Schreijer 写道:
>> Could you please retry this with the 2.3RC1 version? some changes have been made with the configuration files.
>>
>
> they all behave the same among version 2.3.0-rc1, 2.2.3-rc2, 2.2.0. they use the default.
>

sorry, I mean 2.2.2 not 2.2.0. actually 2.2.2 works fine. It didn't work when I checked it because
I installed several different versions side by side and I messed up the environments.
when I start a fresh cmd.exe and call luarocks 2.2.2, it works fine.


> actually if I place a configuration file at %appdata%\luarocks\config-5.2.lua then luarocks
> will use it, but luarocks always ignores the one at D:\Applications\luarocks\config-5.2.lua,
> which is generated automatically by the install.bat script; it is just not loaded at all!
>
> I wonder whether this is a Windows specific behavior, please?
>
After some examination for the code, I guess it is the install.bat that is broken. when I trace the
flow I find the site_cofig_5_2.lua contains the following line:

 >
 >local site_config = {}
 >--[[...]]
 >site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]
 >--[[...]]
 >return site_config
 >

apparently the CONFIG_FILE variable is not expanded properly while generating site_config.lua
I am not very familiar with how luarocks works, could someone please check that out?



--
the nerdy Peng / 书呆彭 / Sent from Thunderbird



Reply | Threaded
Open this post in threaded view
|

Re: luarocks config problem on Windows

Jonathan Goble
On Thu, Dec 24, 2015 at 10:46 PM, 书呆彭, Peng Yi <[hidden email]> wrote:
>>site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]
>
> apparently the CONFIG_FILE variable is not expanded properly while
> generating site_config.lua
> I am not very familiar with how luarocks works, could someone please check
> that out?

Windows batch files don't use $var for variable expansion. The proper
syntax is %var% (here, %CONFIG_FILE%).

Reply | Threaded
Open this post in threaded view
|

Re: luarocks config problem on Windows

彭 书呆
在 2015/12/25 11:52, Jonathan Goble 写道:
> On Thu, Dec 24, 2015 at 10:46 PM, 书呆彭, Peng Yi <[hidden email]> wrote:
>>> site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]
>> apparently the CONFIG_FILE variable is not expanded properly while
>> generating site_config.lua
>> I am not very familiar with how luarocks works, could someone please check
>> that out?
> Windows batch files don't use $var for variable expansion. The proper
> syntax is %var% (here, %CONFIG_FILE%).
>

actually the variable is not expanded by the cmd shell, it is expanded by the
installer script itself. the installer script is a lua script using some shell
commentary trick to run as a batch file.

I think the the script at line 986 missed a `S' call which expands the variables.
below is the trivial fix.

======================= patch ===========================
@@ -983,7 +983,7 @@
      f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n")
  end
  if vars.SYSCONFFORCE then  -- only write this value when explcitly given, otherwise rely on defaults
-    f:write(S"site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]\n")
+    f:write("site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]\n")
  end
  f:write("return site_config\n")
  f:close()
====================== end patch =========================

--
the nerdy Peng / 书呆彭 / Sent from Thunderbird



Reply | Threaded
Open this post in threaded view
|

RE: luarocks config problem on Windows

Thijs Schreijer
Thanks for the detailed analysis. You're right about the missing `S` call. It's also still in the current master branch.

Will push a change there, will be fixed in the next release.

Thanks again for your work!

regards
Thijs

________________________________________
From: [hidden email] [[hidden email]] on behalf of 书呆彭, Peng Yi [[hidden email]]
Sent: 25 December 2015 05:20
To: [hidden email]
Subject: Re: luarocks config problem on Windows

在 2015/12/25 11:52, Jonathan Goble 写道:
> On Thu, Dec 24, 2015 at 10:46 PM, 书呆彭, Peng Yi <[hidden email]> wrote:
>>> site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]
>> apparently the CONFIG_FILE variable is not expanded properly while
>> generating site_config.lua
>> I am not very familiar with how luarocks works, could someone please check
>> that out?
> Windows batch files don't use $var for variable expansion. The proper
> syntax is %var% (here, %CONFIG_FILE%).
>

actually the variable is not expanded by the cmd shell, it is expanded by the
installer script itself. the installer script is a lua script using some shell
commentary trick to run as a batch file.

I think the the script at line 986 missed a `S' call which expands the variables.
below is the trivial fix.

======================= patch ===========================
@@ -983,7 +983,7 @@
      f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n")
  end
  if vars.SYSCONFFORCE then  -- only write this value when explcitly given, otherwise rely on defaults
-    f:write(S"site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]\n")
+    f:write("site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]\n")
  end
  f:write("return site_config\n")
  f:close()
====================== end patch =========================

--
the nerdy Peng / 书呆彭 / Sent from Thunderbird