Im a bit of a luarocks noob, but have done a fair bit of lua coding. I can't find the answer to this anywhere;
Ive installed a new luarock (lua-resty-auto-ssl) via:
luarocks install --tree lualib lua-resty-auto-ssl
This installs to my directory with no problems, however I don't have any .lua files.
I can see in the rock_manifest file they are all listed.
How do I install the .lua files?
After running luarocks install --tree lualib lua-resty-auto-ssl, I have a directory with the following content:
lualib
lualib/share
lualib/share/lua
lualib/share/lua/5.3
lualib/share/lua/5.3/resty
lualib/share/lua/5.3/resty/auto-ssl.lua
lualib/share/lua/5.3/resty/auto-ssl
lualib/share/lua/5.3/resty/auto-ssl/storage_adapters
lualib/share/lua/5.3/resty/auto-ssl/storage_adapters/redis.lua
lualib/share/lua/5.3/resty/auto-ssl/storage_adapters/file.lua
lualib/share/lua/5.3/resty/auto-ssl/jobs
lualib/share/lua/5.3/resty/auto-ssl/jobs/renewal.lua
lualib/share/lua/5.3/resty/auto-ssl/vendor
lualib/share/lua/5.3/resty/auto-ssl/vendor/shell.lua
lualib/share/lua/5.3/resty/auto-ssl/vendor/sockproc
lualib/share/lua/5.3/resty/auto-ssl/vendor/letsencrypt.sh
lualib/share/lua/5.3/resty/auto-ssl/storage.lua
lualib/share/lua/5.3/resty/auto-ssl/ssl_certificate.lua
lualib/share/lua/5.3/resty/auto-ssl/init.lua
lualib/share/lua/5.3/resty/auto-ssl/servers
lualib/share/lua/5.3/resty/auto-ssl/servers/challenge.lua
lualib/share/lua/5.3/resty/auto-ssl/servers/hook.lua
lualib/share/lua/5.3/resty/auto-ssl/utils
lualib/share/lua/5.3/resty/auto-ssl/utils/run_command.lua
lualib/share/lua/5.3/resty/auto-ssl/utils/shell_execute.lua
lualib/share/lua/5.3/resty/auto-ssl/utils/start_sockproc.lua
lualib/share/lua/5.3/resty/auto-ssl/init_worker.lua
lualib/share/lua/5.3/resty/auto-ssl/ssl_providers
lualib/share/lua/5.3/resty/auto-ssl/ssl_providers/lets_encrypt.lua
lualib/share/lua/5.3/resty/auto-ssl/shell
lualib/share/lua/5.3/resty/auto-ssl/shell/start_sockproc
lualib/share/lua/5.3/resty/auto-ssl/shell/letsencrypt_hooks
lualib/share/lua/5.3/resty/http_headers.lua
lualib/share/lua/5.3/resty/http.lua
lualib/lib64
lualib/lib64/luarocks
lualib/lib64/luarocks/rocks
lualib/lib64/luarocks/rocks/manifest
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1/rock_manifest
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1/lua-resty-auto-ssl-0.9.0-1.rockspec
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1/doc
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1/doc/CHANGELOG.md
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1/doc/LICENSE.txt
lualib/lib64/luarocks/rocks/lua-resty-auto-ssl/0.9.0-1/doc/README.md
lualib/lib64/luarocks/rocks/lua-resty-http
lualib/lib64/luarocks/rocks/lua-resty-http/0.09-0
lualib/lib64/luarocks/rocks/lua-resty-http/0.09-0/rock_manifest
lualib/lib64/luarocks/rocks/lua-resty-http/0.09-0/lua-resty-http-0.09-0.rockspec
lualib/lib64/luarocks/rocks/lua-resty-http/0.09-0/doc
lualib/lib64/luarocks/rocks/lua-resty-http/0.09-0/doc/README.md
lualib/lib64/luarocks/rocks/lua-resty-http/0.09-0/doc/LICENSE
There are plenty of Lua files there. What result do you get?
(I don't think it will matter much, but: I'm using Lua 5.3 with LuaRocks 2.3.0)
Related
When trying to link to a system-installed library through Swift Package Manager, specifying it under pkgConfig, it says that the installed package wasn't found in the pkg-config search path. It suggests finding the .pc file that comes with the module but there isn't one.
How do I go about linking the library with SPM?
The way I went about it is creating the .pc file and putting it into /usr/local/lib/pkgconfig, where .pc files are kept, on your own.
.pc files essentially follow the following format:
Defined variables
Name, Description, Version
Libs and Cflags
So for example:
prefix=/usr/local/ModuleFolder
libdir=${prefix}/lib
includedir=${prefix}/include
Name: samplemodule
Description: Appears in a Stack Overflow answer.
Version: 1.0.0
Libs: -L${libdir}
Cflags: -I${includedir}
You can check if pkg-config now detects the file with pkg-config yourmodule --libs --cflags and if so then it should work in Package.swift as well.
If the application was installed through Homebrew, the missing .pc file issue should probably be reported to the developers, although they may not want to implement it in some cases.
More info on pkg-config files can be found at https://people.freedesktop.org/~dbn/pkg-config-guide.html
I followed this manual in order to visualize my QISKit v0.4.8 quantum circuit by means of the latex_drawer() function (in newer versions of QISKit the function is circuit_drawer()). However, I got the following error when running the code:
! LaTeX Error: File `qcircuit.sty' not found.
Is qcircuit.sty a part of QISKit? What is the best way to fix the issue?
By the way, this is the function that I use to produce the image of a circuit:
def circuit_image(circuit, basis="u1,u2,u3,cx"):
filename = 'circuit'
tmpdir = 'tmp'
if not os.path.exists(tmpdir):
os.makedirs(tmpdir)
filename_tex = filename + ".tex"
filename_pdf = filename + ".pdf"
latex_drawer(circuit, os.path.join(tmpdir, filename_tex), basis=basis)
os.system("pdflatex -output-directory {} {}".format(tmpdir, filename_tex))
images = pdf2image.convert_from_path(os.path.join(tmpdir, filename_pdf))
shutil.rmtree(tmpdir)
return images[0]
qcircuit is a third-party LaTeX package that is not part of QISKit. If your LaTeX distribution does not come with this package, you can install it by yourself.
For example, for Ubuntu 14.04.5 LTS do the following:
Download the zip-file
Unpack it to /usr/share/texlive/texmf-dist/tex/latex
Run sudo texhash
For more information on installing LaTeX packages, see the following pages:
Best way to install packages for TeXLive in Ubuntu?
How to install LaTeX packages for Tex Live?
I am the developer of this small library: https://github.com/martin-damien/babel and I have a problem with Luarocks releases.
From source
When I install from source with Luarocks I have no problem:
$ luarocks make --local rockspecs/babel-1.2-2.rockspec
From internet
But when deployed (using: tag master, add new rockspec release and publish to Luarocks), I can't install using
$ luarocks install --local babel
Because I encounter the following error:
Installing https://luarocks.org/babel-1.2-2.src.rock...
Using https://luarocks.org/babel-1.2-2.src.rock... switching to 'build' > mode
stat: malsukcesis eltrovi statinformon pri «locales/zh-HK.lua»: No such > file or directory
Error: Build error: Failed installing locales/zh-HK.lua in /home/damien/.luarocks/lib/luarocks/rocks/babel/1.2-2/lua/locales/zh-HK.lua: locales/zh-HK.lua: No such file or directory
As you can see in https://github.com/martin-damien/babel/issues/14 the error occure on different files (but until now, only with locale files, not with the babel.lua file).
I have no idea why it randomly crash like this, so if someone know why or have an idea from where it could come from...
Thanks in advance,
Damien
The location of the files in the build.modules table is (from the docs on the rockspec format):
relative to source.dir
Where source.dir is
source.dir (string) - the name of the directory created when the source archive is unpacked. Can be omitted if it can be inferred from the source.file field. Example: "luasocket-2.0.1"
and source.file is
source.file (string) - the filename of the source archive. Can be omitted if it can be inferred from the source.url field. Example: "luasocket-2.0.1.tar.gz"
You don't specify source.dir or source.file in your rockspec but you do set source.url (because you have to).
So you have source.url = https://github.com/martin-damien/babel/archive/v1.2-2.zip which (presumably) ends up with source.file = v1.2-2.zip and then source.dir = v1.2-2 but your zip file extracts into a babel-1.2 so luarocks can't find your source files. (The screenshot in the linked issue seems to indicate that luarocks uses source.file = v1.2.zip and the archive extracts to babel-1.2 but I'm not sure how that's possible.)
Add dir = "babel-1.2" to your rockspec's source table an I expect it will work.
I'm attempting to create a Homebrew formula for gtk-mac-integration. Running make in bindings/python/gtkosx_application fails:
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/usr/local/Cellar/gtk-mac-integration/2.0.7/share/pygobject/2.0/codegen/h2def.py': [Errno 2] No such file or directory
make[3]: *** [gtkosx_application.defs] Error 2
This is because the Makefile tries to find the h2def.py file in the wrong location:
gtkosx_application.defs: $(headers)
$(PYTHON) $(datadir)/pygobject/2.0/codegen/h2def.py $(headers) > $#
It is clear to me why this is failing: $(datadir) points to the share directory of the package that is to be installed (gkt-mac-integration). Because Homebrew installs all packages into their own prefix (/usr/local/Cellar/...), it is not the same for gtk-mac-integration and pygobject.
I know it is possible to find out where the pygobject data directory is located using
pkg-config --variable=datadir pygobject-2.0
I don't suppose the correct fix is to replace datadir in the Makefile with the string above? How should I adjust configure.ac and Makefile.am to make this work properly?
Yeah, that sounds like a bug in the build system.
You can use the inreplace facility to patch this up. Insert this after def install:
inreplace %w[bindings/python/gtkmacintegration/Makefile.am
bindings/python/gtkmacintegration/Makefile.in
bindings/python/gtkosx_application/Makefile.am
bindings/python/gtkosx_application/Makefile.in],
'$(datadir)/pygobject', |
%x[pkg-config --variable=datadir pygobject-2.0].chomp + '/pygobject'
(I tried this out. The formula builds after that.)
You should report this upstream. They should change their build system to sort this out in their configure script.
I downloaded the source of LuaJIT and compiled it with msvc120.dll (VS 2013 x64). When I run it from the command line I have no problems executing some basic lua. Now the LuaJIT installation guide mentions moving luajit.exe and lua51.dll into their own folder. From there it says to create a lua folder and under that a jit folder with the contents of src/jit moved underneath the newly created jit folder.
From my understanding my folder should look like and contain:
luajit.exe
lua51.dll
/lua
/jit
bc.lua
[rest of jit files]
vmdef.lua
Is this correct or am I missing files?
Now after I built my luajit I tried to wire it up into my luarocks to act as my interpreter using
install.bat /LUA C:\LuaJIT\2.0.3\[folder with above content]
However this cannot find the header files. I then copied over what are the header files into the folder above and that wires it up, but I can never actually get anything to compile when pointed over to LuaJIT. Edit: The error I get is the following,
C:\LuaJIT\2.0.3\bin\lua51.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2D0
Error: Failed installing dependency: https://rocks.moonscript.org/luafilesystem-1.6.2-2.src.rock - Build error: Failed compiling module lfs.dll
Is the correct way to handle this to simply point to my lua binaries and from there leverage LuaJIT to run my files or am I doing something wrong with wiring up LuaJIT and luarocks? The former seems to work for the most part, since I only ran into one library compilation issue, lua-cjson.
I've run on exactly the same problem, but they've found a solution right here:
https://github.com/keplerproject/luafilesystem/issues/22
I knew that for "linking DLLs statically" there is a so-called "export" .lib file, which is passed to the linker (and not the DLL itself).
So, for example, when compiling, LuaRocks was doing this:
cl /nologo /MD /O2 -c -Fosrc/mime.obj -ID:/LuaJIT-2.0.4/include/ src/mime.c -DLUA_COMPAT_APIINTCASTS -DLUASOCKET_DEBUG -DNDEBUG -DLUASOCKET_API=__declspec(dllexport) -DMIME_API=__declspec(dllexport) mime.c
link -dll -def:core.def -out:mime/core.dll D:/LuaJIT-2.0.4/bin/lua51.dll src/mime.obj
My LuaJIT was compiled from source in D:\LuaJIT-2.0.4\src, but I made two folders myself: D:\LuaJIT-2.0.4\include with all *.h files copied from src and D:\LuaJIT-2.0.4\bin with luajit.exe, lua51.dll, and then later lua51.exp and lua51.lib. Still same error, but this was the right track.
Fix
Now, check where your LuaRocks configs are:
luarocks.bat help
Scroll down to a section like:
CONFIGURATION
Lua version: 5.1
Configuration files:
System: D:/luarocks/config-5.1.lua (ok)
User : (... snip ...)
Edit the System configuration file, specifically see the part:
variables = {
MSVCRT = 'VCRUNTIME140',
LUALIB = 'lua51.dll'
}
Here! LUALIB should be the .lib file. If your export lib is alongside the DLL, you just need to change to:
variables = {
MSVCRT = 'VCRUNTIME140',
LUALIB = 'lua51.lib' -- here!
}
Verification
And now:
luarocks.bat install luasocket
(...)
link -dll -def:core.def -out:socket/core.dll D:/LuaJIT-2.0.4/bin/lua51.lib src/luasocket.obj (...)
(...)
luasocket 3.0rc1-2 is now built and installed in D:\luarocks\systree (license: MIT)
Note the first argument passed to the linker.