I have this lua file:
-- test1.lua
--require "luarocks.loader"
vips = require "vips"
--vips = require "lua-vips"
local img = vips.Image.new_from_file("img1.jpg")
-- [...................]
It won't find the library "lua-vips" installed via "luarocks":
$ luajit test1.lua
luajit: error loading module 'vips' from file '/usr/local/lib/luarocks/rocks-5.3/':
cannot read /usr/local/lib/luarocks/rocks-5.3/: Is a directory
stack traceback:
[C]: at 0x0102caa660
[C]: in function 'require'
test1.lua:2: in main chunk
[C]: at 0x0102c3b8a0
Even after I add
export LUA_PATH="/usr/local/lib/luarocks/rocks-5.3/"
to ~/.profile, it won't.
The content of the directory luarocks -- lua-vips exists:
ls /usr/local/lib/luarocks/rocks-5.3/
lua-vips manifest
How how to fix this?
$ luarocks path
export LUA_PATH='/Users/my_user/.luarocks/share/lua/5.3/?.lua;/Users/my_user/.luarocks/share/lua/5.3/?/init.lua;/usr/local/share/lua/5.3/?.lua;/usr/local/share/lua/5.3/?/init.lua;/usr/local/Cellar/luarocks/3.0.1/share/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua'
export LUA_CPATH='/Users/my_user/.luarocks/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/loadall.so;./?.so'
export PATH='/Users/my_user/.luarocks/bin:/usr/local/bin:/Users/my_user/.yarn/bin:/Users/my_user/.config/yarn/global/node_modules/.bin:/Users/my_user/.nix-profile/bin:/Users/my_user/.nvm/versions/node/v8.14.0/bin:/Users/my_user/.cargo/bin:/Users/my_user/.gem/ruby/2.5.1/bin:/Users/my_user/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/bin:/Users/my_user/.rubies/ruby-2.5.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/my_user/go/bin'
Your problem is that LUA_PATH doesn't work the same way PATHs usually work.
You don't give it a directory, but a template string with an ? representing the name of the library to load.
So, for example, if you want to find files in the /path/to/libs/ directory, you'd write "/path/to/libs/?.lua;/path/to/libs/?/init.lua" for the path.
If you literally add "/usr/local/lib/luarocks/rocks-5.3/", Lua will try to load that directory as a Lua file, which causes your error.
Remove that environment variable and tell us what error you get.
Also keep in mind that adding something to .profile requires logging out and back in again for the changes to take effect (or to source ~/.profile in every new shell you open)
Related
I am trying to run a code using torch7 and LUA and I get this error.
usr/local/torch/install/share/lua/5.2/trepl/init.lua:389: module 'bit' not found: No LuaRocks module found for 'bit'
no field package.preload['bit']
no file '/root/.luarocks/share/lua/5.2/bit.lua'
no file '/root/.luarocks/share/lua/5.2/bit/init.lua'
no file '/usr/local/torch/install/share/lua/5.2/bit.lua'
no file '/usr/local/torch/install/share/lua/5.2/bit/init.lua'
no file '/usr/local/torch/install/lib/lua/5.2/bit.lua'
no file '/usr/local/torch/install/lib/lua/5.2/bit/init.lua'
no file './bit.lua'
no file '/home/shaurovd/.luarocks/share/lua/5.2/bit.lua'
no file '/home/shaurovd/.luarocks/share/lua/5.2/bit/init.lua'
no file '/root/.luarocks/lib/lua/5.2/bit.so'
no file '/usr/local/torch/install/lib/lua/5.2/bit.so'
no file '/usr/local/torch/install/lib/lua/5.2/loadall.so'
no file './bit.so'
no file '/home/shaurovd/.luarocks/lib/lua/5.2/bit.so'
stack traceback:
[C]: in function 'error'
/usr/local/torch/install/share/lua/5.2/trepl/init.lua:389: in function 'require'
train.lua:16: in main chunk
[C]: in function 'dofile'
...ocal/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: in ?
Segmentation fault (core dumped)
I tried to install 'bit' locally in my profile as I don't have the write permission on the server (Ubuntu 18.04) I am working on using:
luarocks install --deps bit --local
But it shows: Error: No results matching query were found.
How do I solve this?
i solved it by running this command
luarocks install luaossl OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong
check this post here github kong issue
I am trying to implement a library which is a Github project on 3D reconstruction using a single image in Ubuntu 16.04. I have installed all dependencies. I have checked if each dependency is correctly installed with help from Google searches and stackoverflow.
But, when I am executing the ./run.sh as mentioned in the Github page, I get the following error.
/home/username/torch/install/bin/luajit: /home/username/torch/install/share/lua/5.1/trepl/init.lua:389: /home/username/torch/install/share/lua/5.1/trepl/init.lua:389: module 'fb.python' not found:No LuaRocks module found for fb.python
no field package.preload['fb.python']
no file '/home/username/.luarocks/share/lua/5.1/fb/python.lua'
no file '/home/username/.luarocks/share/lua/5.1/fb/python/init.lua'
no file '/home/username/torch/install/share/lua/5.1/fb/python.lua'
no file '/home/username/torch/install/share/lua/5.1/fb/python/init.lua'
no file './fb/python.lua'
no file '/home/username/torch/install/share/luajit-2.1.0-beta1/fb/python.lua'
no file '/usr/local/share/lua/5.1/fb/python.lua'
no file '/usr/local/share/lua/5.1/fb/python/init.lua'
no file '/home/username/.luarocks/lib/lua/5.1/fb/python.so'
no file '/home/username/torch/install/lib/lua/5.1/fb/python.so'
no file '/home/username/torch/install/lib/fb/python.so'
no file './fb/python.so'
no file '/usr/local/lib/lua/5.1/fb/python.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/home/username/.luarocks/lib/lua/5.1/fb.so'
no file '/home/username/torch/install/lib/lua/5.1/fb.so'
no file '/home/username/torch/install/lib/fb.so'
no file './fb.so'
no file '/usr/local/lib/lua/5.1/fb.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'error'
/home/username/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
main.lua:8: in main chunk
[C]: in function 'dofile'
...name/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50
ls: cannot access '*.txt': No such file or directory
This issue is in Torch directory and not in the project.
So please guide me how I can resolve it or what could have gone wrong.
P.S. I am new to Linux.
You need to install Torch first. th and luarocks both commands will be available after you install Torch, see Torch
So I have just installed Lua, Love2D, LuaJIT, and Sublime Text with Lua/Love package. When I then try to run this little program:
function love.draw()
love.graphics.print("Hello World", 400, 300)
end
With CTRL+SHIFT+Band then LuaLove - Run I get this error:
luajit: [path to program]\main.lua:1: attempt to index global 'love' (a nil value)
stack traceback:
[path to program]\main.lua:1: in main chunk
[C]: at 0x00402020
[Finished in 0.0s with exit code 1]
[cmd: ['luajit', '[path to program]\\main.lua']]
[dir: [path to program]]
[path: [every thing in path variable]]
I think it has something to do with that I didn't put Love the right way in the path variable. But it's in there like this: C:\Program Files\LOVE
I hope someone has a solution.
You are running the script you have using luajit interpreter, not LOVE executable, which triggers the error you see (as the LuaJIT interpreter doesn't know anything about love objects). You need to configure LuaLove to use the LOVE executable; see this note in the documentation for details: Both Sublime 2 and 3 require the directory of your LÖVE binary to be part of your PATH variable. You can avoid this by changing the "love" path in the build script. This is more complicated in Sublime 3..
I had installed luaxml module using luarocks. I had used the luaxml to call in a lua script. But getting an error
Lua script:
xml = require("LuaXml");
local xobj = xml.eval('<Cmd Message="Hello"/>');
session:consoleLog("INFO","The message in the XML is "..xobj["Message"].."\n");
Error:
mod_lua.cpp:203 error loading module 'LuaXml' from file '/usr/local/lib/lua
/5.2/LuaXML_lib.so': /usr/local/lib/lua/5.2/LuaXML_lib.so: undefined symbol:
luaopen_LuaXml
stack traceback:
[C]: ?
[C]: in function 'require'
I had seen the concept of add libraries to Lua dynamically but i couldn't understand. Can anyone help me out. Briefly so that how to link the core module luaxml with the script.
Another question how can i test whether the installed module luaxml through luarocks is installed or not.
The output of nm -g /usr/lib/lua/5.1/LuaXML_lib.so tells us that this file exports luaopen_LuaXML_lib, not luaopen_LuaXML, which is what require("LuaXml") needs.
Now I don't know why require("LuaXml") is opening /usr/lib/lua/5.1/LuaXML_lib.so. It should be looking for LuaXM.so or LuaXml.lua, in this order.
LuaXML works by loading LuaXml.lua, which does require("LuaXML_lib"). This then will load LuaXML_lib.so.
Perhaps there is a mistake in your LUA_CPATH or package.cpath.
I'm quite new to Lua and I have some problems with the import mechanism.
From other languages I'm used to do something like this:
include "./lib/mylib.h"
or in general just to pass the local path to the file I would like to include.
Now in Lua it is a bit confusing to me. I read something about that require looks for the library in the lua path.
In my case I would like to create a script that uses the luasocket library but I would like to import it from a local path so that I can deploy it without the need to have it on another machine in the lua path.
From other forums I got solutions like creating a local require function that looks in a given local library folder but that didn't work.
Then I read that I can just type require 'myfile' to import a different file locally but luasocket requires a core.dll and if I just move the lua files of the library to my local path it can't find the dll.
Is there an easy way to solve this. What do I have to do to get this working?
It is sufficient for the .dll extension to be in the LUA_CPATH (so it ends up in package.cpath). For example, put the socket.lua in C:\Foo, and put core.dll in same folder. Then require 'socket' will fail:
> print(package.cpath)
.\?.dll;.\?51.dll;C:\Program Files\Lua\5.1\?.dll;C:\Program Files\Lua\5.1\?51.dl
l;C:\Program Files\Lua\5.1\clibs\?.dll;C:\Program Files\Lua\5.1\clibs\?51.dll;C:
\Program Files\Lua\5.1\loadall.dll;C:\Program Files\Lua\5.1\clibs\loadall.dll
> print(package.path)
;.\?.lua;C:\Program Files\Lua\5.1\lua\?.lua;C:\Program Files\Lua\5.1\lua\?\init.
lua;C:\Program Files\Lua\5.1\?.lua;C:\Program Files\Lua\5.1\?\init.lua;C:\Progra
m Files\Lua\5.1\lua\?.luac
> require 'socket'
.\socket.lua:13: module 'socket.core' not found:
-- look for preload
no field package.preload['socket.core']
-- look for .lua in socket folder anywhere on package.path:
no file '.\socket\core.lua'
no file 'C:\Program Files\Lua\5.1\lua\socket\core.lua'
no file 'C:\Program Files\Lua\5.1\lua\socket\core\init.lua'
...
-- look for .luac in socket folder anywhere on package.path:
no file 'C:\Program Files\Lua\5.1\lua\socket\core.luac'
-- look for .dll in socket folder anywhere on package.cpath:
no file '.\socket\core.dll'
no file '.\socket\core51.dll'
no file 'C:\Program Files\Lua\5.1\socket\core.dll'
no file 'C:\Program Files\Lua\5.1\socket\core51.dll'
no file 'C:\Program Files\Lua\5.1\clibs\socket\core.dll'
no file 'C:\Program Files\Lua\5.1\clibs\socket\core51.dll'
...
stack traceback:
[C]: in function 'require'
.\socket.lua:13: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
because socket.lua requires socket.core, so Lua interpreter looks for core.lua in a "socket" folder anywhere on package.path, doesn't find it (socket folder doesnt' exist), then looks for core.dll in socket folder anywhere on package.cpath, same problem.
Now create C:\Foo\socket folder, and move core.dll to it, then require 'socket' will work (from interpreter started while cd to C:\Foo).
In your case, if you have yourLuaScript.lua in C:\Foo, you could have socket.lua in same folder, core.dll in C:\Foo\socket, and yourLuaScript.lua could require 'socket' and, as long as package.path contains .\*.lua, and package.cpath contains .\*.dll, you will be able to run yourLuaScript.lua.