* [ Q ] Lua-filter: "Dynamic linking not supported" error when loading certain lua module(s)
@ 2019-07-08 12:44 K4zuki
[not found] ` <4337b7eb-3ed7-4a70-a9f5-ecccc625c7d8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: K4zuki @ 2019-07-08 12:44 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1831 bytes --]
Hello,
I am facing a little problem around lua and pre-compiled dynamic
libraries(*.so).
On Ubuntu 18.04(bionic), I have installed '*lyaml*' and '*lfs*' modules
through 'lua-yaml' and 'lua-filesystem' APT packages.
Pandoc version is *2.7.3*
When I try to load *lyaml* by simplest statement like following, Pandoc-lua
raises error
```input
package.path = package.path .. ';/usr/share/lua/5.3/?.lua'
package.cpath = package.cpath .. ";/usr/lib/x86_64-linux-gnu/lua/5.3"
-- those 2 lines above are required to load
local lyaml = require("lyaml")
```
---
```output
error loading module 'yaml' from file
'/usr/lib/x86_64-linux-gnu/lua/5.3/yaml.so':
Dynamic loading not supported
stack traceback:
[C]: in ?
[C]: in function 'require'
/usr/share/lua/5.3/lyaml.lua:31: in main chunk
[C]: in function 'require'
../lua/test.lua:5: in main chunk
```
*lfs* is similar like so:
```
error loading module 'lfs' from file
'/usr/lib/x86_64-linux-gnu/lua/5.3/lfs.so':
Dynamic loading not supported
stack traceback:
[C]: in ?
[C]: in function 'require'
../lua/test.lua:8: in main chunk
```
How can we solve this, or do we need to use static libs only?
Thanks && Regards,
Kazuki / K4zuki
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4337b7eb-3ed7-4a70-a9f5-ecccc625c7d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 4349 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ Q ] Lua-filter: "Dynamic linking not supported" error when loading certain lua module(s)
[not found] ` <4337b7eb-3ed7-4a70-a9f5-ecccc625c7d8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-07-08 13:14 ` BP Jonsson
[not found] ` <CAFC_yuSiX5iPeh69vpy4bB9ZSYPB+BHtZEMJCykHMqgLyRMWJw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: BP Jonsson @ 2019-07-08 13:14 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1: Type: text/plain, Size: 3142 bytes --]
You may have better luck modifying the LUA_PATH environment variable
*before* you run lua/pandoc.
http://www.thijsschreijer.nl/blog/?p=1025
Also there may be problems using non-pure-lua modules if you use the
downloadable relocatable pandoc binary. I guess that is what you are
running into here.
Den mån 8 juli 2019 14:44K4zuki <k.yamamoto.08136891-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
> Hello,
>
> I am facing a little problem around lua and pre-compiled dynamic
> libraries(*.so).
>
> On Ubuntu 18.04(bionic), I have installed '*lyaml*' and '*lfs*' modules
> through 'lua-yaml' and 'lua-filesystem' APT packages.
> Pandoc version is *2.7.3*
>
> When I try to load *lyaml* by simplest statement like following,
> Pandoc-lua raises error
> ```input
> package.path = package.path .. ';/usr/share/lua/5.3/?.lua'
> package.cpath = package.cpath .. ";/usr/lib/x86_64-linux-gnu/lua/5.3"
> -- those 2 lines above are required to load
> local lyaml = require("lyaml")
> ```
> ---
> ```output
> error loading module 'yaml' from file
> '/usr/lib/x86_64-linux-gnu/lua/5.3/yaml.so':
> Dynamic loading not supported
> stack traceback:
> [C]: in ?
> [C]: in function 'require'
> /usr/share/lua/5.3/lyaml.lua:31: in main chunk
> [C]: in function 'require'
> ../lua/test.lua:5: in main chunk
> ```
> *lfs* is similar like so:
> ```
> error loading module 'lfs' from file
> '/usr/lib/x86_64-linux-gnu/lua/5.3/lfs.so':
> Dynamic loading not supported
> stack traceback:
> [C]: in ?
> [C]: in function 'require'
> ../lua/test.lua:8: in main chunk
> ```
>
> How can we solve this, or do we need to use static libs only?
>
> Thanks && Regards,
> Kazuki / K4zuki
>
> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/4337b7eb-3ed7-4a70-a9f5-ecccc625c7d8%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/4337b7eb-3ed7-4a70-a9f5-ecccc625c7d8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAFC_yuSiX5iPeh69vpy4bB9ZSYPB%2BBHtZEMJCykHMqgLyRMWJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: Type: text/html, Size: 6322 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ Q ] Lua-filter: "Dynamic linking not supported" error when loading certain lua module(s)
[not found] ` <CAFC_yuSiX5iPeh69vpy4bB9ZSYPB+BHtZEMJCykHMqgLyRMWJw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-07-08 18:41 ` K4zuki
[not found] ` <3922e409-02e2-4ba6-b172-20e3d5bf2d56-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: K4zuki @ 2019-07-08 18:41 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 926 bytes --]
You seem to be totally right: C-based libraries are not supported by
static-built pandoc binaries(e.g. deb file)
I agree that setting LUA_PATH/LUA_CPATH is also preferred.
I will use lua-yaml instead of lyaml package. lfs cannot be used in this
case but as penlight package requires it, I will leave it installed(and
unused).
Thanks for the advice.
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3922e409-02e2-4ba6-b172-20e3d5bf2d56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 1430 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ Q ] Lua-filter: "Dynamic linking not supported" error when loading certain lua module(s)
[not found] ` <3922e409-02e2-4ba6-b172-20e3d5bf2d56-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-07-12 10:36 ` BPJ
0 siblings, 0 replies; 4+ messages in thread
From: BPJ @ 2019-07-12 10:36 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 4435 bytes --]
Do you know that you can use Pandoc itself as a YAML parser?
https://pandoc.org/lua-filters.html#default-metadata-file
Some things to look out for:
- Pandoc parses YAML scalar values (but not keys) as Pandoc markdown and
returns a tree of objects. To get a "plain" data structure out of that you
have to run the `meta` part of the Pandoc object through a function along
the lines of
````lua
local function meta2data (x)
if 'table' == type(x) then
local t = x.t -- tag == element type
if not t or 'MetaMap' == t or 'MetaList' == t then
-- turn into a plain data table
local d = {}
for k,v in pairs(x) do
d[k] = meta2data(v) -- call recursively
end
return d
elseif t then
-- probably text, so stringify it
return pandoc.utils.stringify(x)
end
else
-- something else, probably a string or boolean
return x
end
end
local data = meta2data(doc.meta)
-- or less expensively:
local some_data = meta2data(doc.meta.some_field)
````
NOTE: I'm "quoting" the meta2data function from brain memory so some
detail covering some edge case may be missing, but it's the general idea.
- The restringification of the MetaBlocks and MetaInlines elements (or
rather their contents) removes everything which Pandoc considers
formatting, so you, or your users, have to wrap any literal strings in the
YAML where whitespace and/or punctuation is important in Pandoc code
elements, and these need in turn to be wrapped in YAML quoted strings since
YAML reserves the backtick for future use as a metacharacter:
````````yaml
foo: '`2**10`'
bar: |
````
No Markdown parsing here
````
````````
- If you read in YAML from a file you have to make sure that it starts
and ends with appropriate YAML block delimiters so that Pandoc recognises
it as "metadata"
````lua
if not yaml:match('^%-%-%-%f[^%-]') then
yaml = "---\n" .. yaml
end
if not yaml:match('\n([%.%-])%1%1%s*$') then
yaml = yaml .. "\n...\n"
end
````
This looks complicated but the first two points are generally what you have
to do/observe anyway if you configure your filter through metadata, and
having Pandoc parse the YAML using Haskell is probably still more efficient
and robust than using a pure Lua YAML parser. (I've taken a stab at
reimplementing [YAML::Tiny](https://metacpan.org/pod/YAML::Tiny) in Lua and
it isn't easy!)
Den mån 8 juli 2019 20:41K4zuki <k.yamamoto.08136891-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
> You seem to be totally right: C-based libraries are not supported by
> static-built pandoc binaries(e.g. deb file)
> I agree that setting LUA_PATH/LUA_CPATH is also preferred.
>
> I will use lua-yaml instead of lyaml package. lfs cannot be used in this
> case but as penlight package requires it, I will leave it installed(and
> unused).
>
> Thanks for the advice.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/3922e409-02e2-4ba6-b172-20e3d5bf2d56%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/3922e409-02e2-4ba6-b172-20e3d5bf2d56%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhDYBysaQv%3DONc9roHxumJs5pE%3D4Ex_fe11GOrWPdMOc0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: Type: text/html, Size: 7092 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-12 10:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 12:44 [ Q ] Lua-filter: "Dynamic linking not supported" error when loading certain lua module(s) K4zuki
[not found] ` <4337b7eb-3ed7-4a70-a9f5-ecccc625c7d8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-07-08 13:14 ` BP Jonsson
[not found] ` <CAFC_yuSiX5iPeh69vpy4bB9ZSYPB+BHtZEMJCykHMqgLyRMWJw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-07-08 18:41 ` K4zuki
[not found] ` <3922e409-02e2-4ba6-b172-20e3d5bf2d56-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-07-12 10:36 ` BPJ
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).