gvvaughan / lyaml Goto Github PK
View Code? Open in Web Editor NEWLibYAML binding for Lua.
Home Page: gvvaughan.github.io/lyaml
License: Other
LibYAML binding for Lua.
Home Page: gvvaughan.github.io/lyaml
License: Other
It is possible to keep the YAML structure order ?
let say this yaml string
key1: 1
key2: 2
key2: 3
lyaml.load(my_yaml_string)
will return
{
key33
key11
key22
}
or
{
key11
key33
key22
}
or any another combination.
It is possible to keep the order?
It causes problem in strict enviroment.
Use it with openResty this would causes lot's of warning message; and in some custom enviroment it's impossible to write into _G
.
I have installed luarocks for a customised lua version based on 5.1. and now trying to install specl which depends on lyaml. and getting this error. I thought this was fixed in latest version.
`root@b8b290eb659a:/opt/luarocks5_1/bin# ./luarocks install specl
Installing https://luarocks.org/specl-14.1.7-1.src.rock
Missing dependencies for specl 14.1.7-1:
lyaml >= 5 (not installed)
optparse (not installed)
stdlib >= 41.2.0, < 42.0 (not installed)
specl 14.1.7-1 depends on luamacro >= 2.0 (2.5.1-1 installed)
specl 14.1.7-1 depends on lua >= 5.1, < 5.5 (5.1-1 provided by VM)
specl 14.1.7-1 depends on lyaml >= 5 (not installed)
Installing https://luarocks.org/lyaml-6.2.5-1.src.rock
lyaml 6.2.5-1 depends on lua >= 5.1, < 5.5 (5.1-1 provided by VM)
/<>j/bin/lua build-aux/luke package="lyaml" version="6.2.5" PREFIX="/opt/luarocks5_1/lib/luarocks/rocks-5.1/lyaml/6.2.5-1" CFLAGS="-O2 -fPIC" LIBFLAG="-shared" LIB_EXTENSION="so" OBJ_EXTENSION="o" LUA="/opt/<>j/bin/lua" LUA_DIR="/opt/luarocks5_1/lib/luarocks/rocks-5.1/lyaml/6.2.5-1/lua" LUA_INCDIR="/opt/<>/include/lua" YAML_DIR="/usr" YAML_INCDIR="/usr/include" YAML_LIBDIR="/usr/lib/x86_64-linux-gnu"
luke: fatal: required symbol 'yaml_document_initialize' not found in any of libc, libyaml
Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.5-1.src.rock - Build error: Failed building.
root@b8b290eb659a:/opt/luarocks5_1/bin# ls
`
Hi,
Would this package able to install using Brew?
I've tried but no luck at the moment to install it with Brew. Following are the Brew script generated using brew create ...
:
class Lyaml < Formula
desc "LibYAML binding for Lua"
homepage "https://gvvaughan.github.io/lyaml"
url "https://github.com/gvvaughan/lyaml/archive/refs/tags/v6.2.7.tar.gz"
sha256 "9bb489cefae48b150d66f6bab4141d8d5831fcb7465bfc52a9845fa01efc63b0"
license "MIT"
def install
system "./configure", *std_configure_args, "--disable-silent-rules"
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! For Homebrew/homebrew-core
# this will need to be a test that verifies the functionality of the
# software. Run the test with `brew test lyaml`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "false"
end
end
I have issue when install the Kong Gateway, which depends on this package - no package available in Brew yet for lyaml.
I'm getting install errors when trying to install lyaml
via luarocks
on both OSX and Photon OS (Linux).
$ sudo luarocks-5.1 install lyaml 6.2
Installing https://luarocks.org/lyaml-6.2-1.src.rock...
Using https://luarocks.org/lyaml-6.2-1.src.rock... switching to 'build' mode
Error: Could not find library file for YAML
No file libyaml.a in /usr/local/lib
No file libyaml.dylib in /usr/local/lib
No file matching libyaml.so.* in /usr/local/lib
No file libyaml.a in /usr/lib
No file libyaml.dylib in /usr/lib
No file matching libyaml.so.* in /usr/lib
You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.
Example: luarocks install lyaml YAML_DIR=/usr/local
Any idea what I'm missing? Here are the lua
and luarocks
versions I'm using:
15:13 $ lua-5.1 -v
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
✔ ~/.kube
15:13 $ luarocks-5.1 | head -2
LuaRocks 2.3.0, a module deployment system for Lua
NOTE: On my attempts to get this working with Photon OS (which is my primary goal), I'm using LuaJIT 2.1.0-beta2
Would it be at all possible to retain line number information for entries?
`result = lyaml.dump([[
foo:
I would like to get the information that foo[2]
lives in line 4 of the input.
Two approaches come to mind:
getmetatable(result.foo[2].line)
result, lines = lyaml.dump(input, { lines = true } )
I could do either:
assert(lines[foo[2]] == 4)
assert(lines.foo[2] == 4)
-- this option would allow us to even do assert(lines.foo[2].bla)
to get the position of non-table items tooWould something among these lines be a desirable feature? Are there any implementation hurdles to this I should be aware of in case I try implementing it? (i.e. does libyaml return position information?)
Tried building lyaml from a rockspec, got this:
checking if Lua header version matches 5.1... no
configure: error: cannot find headers for specified LUA_INCLUDE
Couldn't find any settings of LUA_INCLUDE / LUA that worked, so I tried building from source, which gives:
bootstrap: error: Prerequisite LuaRock 'specl 14' not found. Please install it.
bootstrap: error: Missing rocks:
However:
$ luarocks install specl
Installing https://luarocks.org/specl-14.1.2-1.src.rock...
Using https://luarocks.org/specl-14.1.2-1.src.rock... switching to 'build' mode
Missing dependencies for specl:
lyaml >= 5
Hi, I'd like YAML 1.2 support.
Hi.
I propose to stick to a more common names for encoding/decoding of API:
...
local luatable = { ... }
local lyaml.encode(luatable)
yamlString = lyaml.decode(...)
The naming is currently not obvious. Thanks!
Hi, I found a problem, looks like memory leak, in lua-5.1.4. see the following image and code.
the code:
local lyaml = require("lyaml")
local pok, tb = pcall(lyaml.load, "_format_version: '1.1'")
for i = 1, 1000000000 do
local yaml, err = lyaml.dump({tb})
end
and the mem of flamegraph, maybe the problem is Pemitter()
or emit()
:
On my investigation towards generating a yaml with sorted keys (#45), I realized that I need is the Dumper object used in lyaml/init.lua
with a small tweak to the dump_mapping
function.
It seems that the only way for me to accomplish this would be to copy-paste the whole implementation of dumper_mt
.
I realize that this might be a philosophical point about design, but this feels "wrong" to me.
I see two approaches that would make this less painful:
Dumper
and Parser
directly in the lyaml librarylocal Dumper = require('lyaml').Dumper`)
Then I would be able to build/customize my custom dumper file easily.
This would be trivial to implement, but perhaps a bit "crude". It also opens the door for global modifications of the library (someone could decide to monkeypatch the global Dumper object, instead of using it to build a new Dumper object and using that).
options
parameterlocal str = lyaml.dump(tbl, { dump_mapping = my_custom_dump_mapping })
I... honestly don't see a lot of big drawbacks to this one. It seems simple to implement and can be done without exposing global variables for modification.
Would you be open to accepting a PR on any of these directions?
---
default: &default
value1: 1
value2: 2
hoge:
<<: *default
value3: 3
When the above YAML file parsed, it should be the Lua table shown below:
{
default = {
value1 = 1,
value2 = 2
},
hoge = {
value1 = 1,
value2 = 2,
value3 = 3
}
}
However, it will be the Lua table shown below actually:
{
default = {
value1 = 1,
value2 = 2
},
hoge = {
['<<'] = {
value1 = 1,
value2 = 2
},
value3 = 3
}
}
When dumping small documents for human consumption, I'd like to have an option to suppress document start and end markers.
- Some: data
instead of
---
- Some: data
...
Am I suppose to parse my markdown files for yaml frontmatter first and then supply that to lyaml
or does lyaml
itself have a means for extracting the frontmatter from markdown files?
hi.
root@localhost:/lyaml# specl -v1freport specs/*_spec.yaml/lyaml# find . -name specl
No command 'specl' found, did you mean:
Command 'pecl' from package 'php-pear' (main)
Command 'spell' from package 'spell' (main)
specl: command not found
root@localhost:
root@localhost:~/lyaml#
how to fix it?
local lyaml = require "lyaml"
print(lyaml.dump({{array = {}, object = {}}}))
output:
---
array: []
object: []
...
Lua uses table as array. How to distinguish an empty table and an empty array?
In local.mk, lib_LTLIBRARIES should instead be luaexec_LTLIBRARIES, so that the module will be installed into luaexecdir (e.g. /usr/lib64/lua/5.1, defined by ax_lua.m4) instead of libdir (e.g. /usr/lib).
Hello @gvvaughan ,
I understand that this lib is available over lua rocks.
Can you please let me know if this is available on OPM [https://opm.openresty.org] as openResty has deprecated packages over lua rocks
Which seems to make it impossible to output a truly empty document:
yaml = require "yaml"
emitter = yaml.emitter ()
emitter.emit {type="STREAM_START"}
emitter.emit {type="DOCUMENT_START", implicit=true} -- elides "---"
emitter.emit {type="SCALAR", value=""}
emitter.emit {type="DOCUMENT_END", implicit=true} -- outputs a "..." token anyway ?!?
print (emitter.emit {type="STREAM_END"})
Note that emitting a second set of DOCUMENT_START and DOCUMENT_END tokens before the STREAM_END above does indeed elide the first "..." document end marker, followed by a "---" for the (implicit!) second document start marker.
So, likely this is a "feature" of libYAML... confusing though it is :-/
On NetBSD, a special linker flag needs to be passed for ld.so to correctly load dependencies in nonstandard places - which unfortunately includes /usr/pkg/lib.
It's pretty routine to override LDFLAGS or similar when building with LuaRocks for that reason. However, this package fails:
Nov01:2043 $ sudo luarocks-5.2 install lyaml YAML_DIR=/usr/pkg LIBFLAG='-shared -Wl,-R/usr/pkg/lib'
Warning: falling back to curl - install luasec to get native HTTPS support
Installing https://luarocks.org/lyaml-6.1.3-1.src.rock
/usr/pkg/bin/lua5.2 build-aux/luke package="lyaml" version="6.1.3-1" PREFIX="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1" CFLAGS="-O2 -fPIC" LIBFLAG="-shared -Wl,-R/usr/pkg/lib" LIB_EXTENSION="so" OBJ_EXTENSION="o" LUA="/usr/pkg/bin/lua5.2" LUA_DIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1/lua" LUA_INCDIR="/usr/pkg/include/lua-5.2" YAML_DIR="/usr/pkg" YAML_INCDIR="/usr/pkg/include" YAML_LIBDIR="/usr/pkg/lib"
creating build-aux/config.ld
cc -O2 -fPIC -shared -fPIC -DNDEBUG -D_FORTIFY_SOURCE=2 -D_BSD_SOURCE -DVERSION='"6.1.3-1"' -DPACKAGE='"lyaml"' -Iext/include -I/usr/pkg/include/lua-5.2 -I/usr/pkg/include ext/yaml/yaml.c ext/yaml/emitter.c ext/yaml/parser.c ext/yaml/scanner.c -o netbsd/yaml.so -L/usr/pkg/lib -lyaml
true -c build-aux/config.ld .
/usr/pkg/bin/lua5.2 build-aux/luke install --quiet INST_LIBDIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1/lib" INST_LUADIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.3-1/lua"
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
WARNING: can't open config file: /etc/openssl/openssl.cnf
lyaml 6.1.3-1 is now installed in /usr/pkg/luarocks (license: MIT/X11)
Nov01:2043 $ ldd /usr/pkg/luarocks/lib/lua/5.2/yaml.so
/usr/pkg/luarocks/lib/lua/5.2/yaml.so:
-lyaml-0.2 => not found
-lgcc_s.1 => /usr/lib/libgcc_s.so.1
-lc.12 => /usr/lib/libc.so.12
You can see in the above that LIBFLAG gets passed down somewhat, but doesn't make it all the way to the CC command (the option '-Wl,-R/usr/pkg/lib' is missing), and thus loading yaml.so fails.
Using LuaJIT on Linux Mint, I get the following error when I call lyaml.dump {{foo="bar"}}
/usr/local/share/lua/5.1/lyaml/init.lua:231: attempt to call field 'emitter' (a nil value)
stack traceback:
/usr/local/share/lua/5.1/lyaml/init.lua:231: in function 'Dumper'
/usr/local/share/lua/5.1/lyaml/init.lua:256: in function 'dump'
stdin:1: in main chunk
[C]: at 0x004044a0
And a very similar error with lyaml.load
, except it's parser
that's nil.
Consider the following YAML file, say y.yaml
2017.11:
2017.11.02:
Then consider the following loading code:
local function loadyaml(config)
local posix = require "posix"
local lyaml = require "lyaml"
local s
if posix.stat(config) ~= nil then
local f = io.open(config)
f:close()
return lyaml.load (s)
end
end
x = loadyaml("y.yaml")
for k,v in pairs(x) do
print(type(k),type(v))
print(k,v)
end
The result is
number table
2017.11 table: 0x5620e93dd8a0
string table
2017.11.02 table: 0x5620e93dd8a0
I know that Lua likes to type things as numbers which can be considered to be numbers under certain circumstances, but is this really appropriate behavior here?
If one simply assigns these values, Lua doesn't type them differently.
foo = "2017.11"
date1 = "2017.11"
print(type(date1))
string
date2 = "2017.11.02"
print(type(date2))
string
Full synopsis here:
I was curious why, when dumping a table, I have to wrap it inside another table. For example, this returns an empty string:
> print(lyaml.dump({ foo = "bar" }))
Whereas if I wrap my table inside another, then I get the expected output:
> print(lyaml.dump({{ foo = "bar" }}))
---
foo: bar
…
This seems confusing since it means I can't actually use lyaml.dump
on a table previously parsed with lyaml.load
without manually adding this extra wrapper table:
> print(lyaml.dump(lyaml.load("foo: bar")))
> print(lyaml.dump({ lyaml.load("foo: bar") }))
---
foo: bar
…
I would expect that first example to work, since intuitively it seems like I should be able to dump something that the library loads without tweaking the object.
So my primary question is whether or not this extra table is purposeful in the lyaml dump API. If it is, then it's easy enough to workaround, but I might recommend documenting it more clearly in the README (I had to look at the test suite to understand this). I'd be happy to submit a pull request with some documentation updates, but I first just wanted to make sure this design was intended when dumping tables.
On a clean install of NetBSD 7.1/amd64, attempting to install with Luarocks, lyaml 6.1.1 fails to build:
Mar28:0015 @xd-ackdev:/usr/pkg/lib/lua/5.2 $ sudo /usr/pkg/bin/luarocks-5.2 install lyaml YAML_DIR=/usr/pkg
Installing https://luarocks.org/lyaml-6.1.1-4.src.rock
/usr/pkg/bin/lua5.2 build-aux/luke package="lyaml" version="6.1.1-4" PREFIX="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.1-4" CFLAGS="-O2 -fPIC" LIBFLAG="-shared" LIB_EXTENSION="so" OBJ_EXTENSION="o" LUA="/usr/pkg/bin/lua5.2" LUA_DIR="/usr/pkg/luarocks/lib/luarocks/rocks-5.2/lyaml/6.1.1-4/lua" LUA_INCDIR="/usr/pkg/include/lua-5.2" YAML_DIR="/usr/pkg" YAML_INCDIR="/usr/pkg/include" YAML_LIBDIR="/usr/pkg/lib"
luke: fatal: required symbol 'yaml_document_initialize' not found in any of libc, libyaml
Error: Build error: Failed building.
The same failure occurs with Lua 5.3. Lyaml version 6.1 installs fine on the same system with either version; It appears the build tool isn't correctly identifying libyaml's headers despite being given the correct path.
anchors and aliases in yaml files do not create shared table entries in the generated Lua data structures.
It seems null
is parsed as a string in lyaml instead of as a 'nil' type, unless I'm missing something. Here's an example showing the issue, and a comparison with what Python does.
https://gist.github.com/achalddave/0c8acc998acb21b4372d02d0b0650b12
build-aux/luke:120: attempt to concatenate local 'found' (a nil value)
stack traceback:
build-aux/luke:120: in function 'check_executable_in_path'
build-aux/luke:197: in function 'block'
build-aux/luke:432: in function 'dropuntil'
build-aux/luke:197: in function 'block'
build-aux/luke:432: in function 'dropuntil'
build-aux/luke:210: in function 'configure'
build-aux/luke:220: in function 'config_ldoc'
build-aux/luke:244: in function 'build_modules'
build-aux/luke:254: in function 'main'
build-aux/luke:618: in main chunk
[C]: at 0x00405060
Oh, I don't understand, no tabs, for god's sake, where are tabs?
local function check_executable_in_path(L,env,config,prog)local PATH=concat(bindirs(config.bindir))..getenv('PATH')local found=dropuntil(gmatch(PATH,'[^:]+'),function(path)local progpath=path..'/'..prog
return with(File(progpath,'r'),function(h)return isfile(h.context)and progpath or nil
end)end)L.debug('found '..found)return found~=nil
end
Thanks for useful module, but this code is horror.
L.debug('found '..found)return found~=nil
here found
is nil and this causes an error.
I would like to order mapping keys in the dump for human readability.
For my use case a flat list is enough.
How about something like this?
yaml.dump(data, { mapping_key_order = { "key1", "key2", ... } }) -- keys not in the list are dumped in the end
and, for finer control:
yaml.dump(data, { mapping_key_order = function(mapping) -- This may be the default if mapping_key_order = true
local keys = tkeys(mapping)
table.sort(keys)
return keys
end }) -- keys not in the list are dumped in the end
If mapping_key_order
is not specified, use the current implementation for performance.
Hi,
would you mind releasing the latest version of lyaml? I am running into build issues on macOS and I believe that your recent changes could help with that.
Thank you!
Hans
build-aux/luke:628: module 'luke' not found:No LuaRocks module found for luke
When I try to load yaml in my openresty
with local settings = lyaml.load(tenant.settings)
it generates this error for me.
2018/03/28 20:28:06 [error] 93756#5408880: *1 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/std/normalize/_strict.lua:33: attempt to index global '_debug' (a nil value)
nginx version: openresty/1.13.6.1
>luarocks install lyaml YAML_DIR="C:\PROGRAM FILES\LIBYAML" YAML_INCDIR="C:\PROGRAM FILES\LIBYAML\INCLUDE" YAML_LIBDIR="C:\PROGRAM FILES\LIBYAML"
Installing https://luarocks.org/lyaml-6.2.8-1.src.rock
lyaml 6.2.8-1 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM)
C:\Program Files\lua/lua.exe build-aux/luke package="lyaml" version="6.2.8" PREFIX="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1" CFLAGS="/nologo /MD /O2" LIBFLAG="/nologo /dll" LIB_EXTENSION="dll" OBJ_EXTENSION="obj" LUA="C:\Program Files\lua/lua.exe" LUA_DIR="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1/lua" LUA_INCDIR="C:\Program Files\lua/include" YAML_DIR="C:\PROGRAM FILES\LIBYAML" YAML_INCDIR="C:\PROGRAM FILES\LIBYAML\INCLUDE" YAML_LIBDIR="C:\PROGRAM FILES\LIBYAML"
C:\Program Files\lua/lua.exe build-aux/luke install --quiet INST_LIBDIR="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1/lib" INST_LUADIR="C:\Users\Leonardus\AppData\Roaming/luarocks/lib/luarocks/rocks-5.4/lyaml/6.2.8-1/lua"
lyaml 6.2.8-1 is now installed in C:\Users\Leonardus\AppData\Roaming/luarocks (license: MIT/X11)
However, lyaml is not installed to %APPDATA%\luarocks\share\lua\5.4
, and attempting to load it fails:
>lua script.lua
lua: script.lua:3: module 'lyaml' not found:
no field package.preload['lyaml']
no file 'C:\Program Files\luarocks\lua\lyaml.lua'
no file 'C:\Program Files\luarocks\lua\lyaml\init.lua'
no file 'C:\Program Files\luarocks\lyaml.lua'
no file 'C:\Program Files\luarocks\lyaml\init.lua'
no file 'C:\Program Files\luarocks\..\share\lua\5.4\lyaml.lua'
no file 'C:\Program Files\luarocks\..\share\lua\5.4\lyaml\init.lua'
no file '.\lyaml.lua'
no file '.\lyaml\init.lua'
no file 'C:\Users\Leonardus\AppData\Roaming/luarocks/share/lua/5.4/lyaml.lua'
no file 'C:\Users\Leonardus\AppData\Roaming/luarocks/share/lua/5.4/lyaml/init.lua'
no file ''
no file 'C:\Program Files\luarocks\lyaml.dll'
no file 'C:\Program Files\luarocks\..\lib\lua\5.4\lyaml.dll'
no file 'C:\Program Files\luarocks\loadall.dll'
no file '.\lyaml.dll'
no file 'C:\Users\Leonardus\AppData\Roaming/luarocks/lib/lua/5.4/lyaml.dll'
no file 'C:\Program Files (x86)\wxLua\bin\lyaml.dll'
no file ''
stack traceback:
[C]: in function 'require'
script.lua:3: in main chunk
[C]: in ?
I attempted to write a rockspec, but there's a linking problem that I've been trying to resolve for about four hours now and I haven't made any progress.
local _MODREV, _SPECREV = 'git', '-1'
package = 'lyaml'
version = _MODREV .. _SPECREV
description = {
summary = 'libYAML binding for Lua',
detailed = 'Read and write YAML format files with Lua.',
homepage = 'http://github.com/gvvaughan/lyaml',
license = 'MIT/X11',
}
source = {
url = 'http://github.com/gvvaughan/lyaml/archive/v' .. _MODREV .. '.zip',
dir = 'lyaml-' .. _MODREV,
}
dependencies = {
'lua >= 5.1, < 5.5',
}
external_dependencies = {
YAML = {
header = 'yaml.h',
--library = 'yaml',
},
}
build = {
type = 'builtin',
modules = {
yaml = {
sources = {
'ext/yaml/emitter.c',
'ext/yaml/parser.c',
'ext/yaml/scanner.c',
'ext/yaml/yaml.c'
},
incdirs = { '$(YAML_INCDIR)', '$(LUA_INCDIR)' },
libdirs = { '$(YAML_LIBDIR)', '$(YAML_BINDIR)' },
libraries = { 'yaml' },
defines = {
'PACKAGE=lyaml',
'VERSION=' .. _MODREV,
'NDEBUG=1',
'_FORTIFY_SOURCE=2'
}
}
},
install = {
lua = {
['lyaml'] = 'lib/lyaml/init.lua',
['lyaml.explicit'] = 'lib/lyaml/explicit.lua',
['lyaml.functional'] = 'lib/lyaml/functional.lua',
['lyaml.implicit'] = 'lib/lyaml/implicit.lua'
},
},
copy_directories = {'doc'}
}
if _MODREV == 'git' then
build.copy_directories = nil
source = {
url = 'git://github.com/gvvaughan/lyaml.git',
}
end
Below is the linking error, if anyone is interested and/or more experienced than me with building on Windows:
>luarocks make YAML_DIR="c:\program files\libyaml"
lyaml git-1 depends on lua >= 5.1, < 5.5 (5.4-1 provided by VM)
cl /nologo /MD /O2 -c -Foext/yaml/emitter.obj -IC:\Program Files\lua/include ext/yaml/emitter.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
emitter.c
cl /nologo /MD /O2 -c -Foext/yaml/parser.obj -IC:\Program Files\lua/include ext/yaml/parser.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
parser.c
cl /nologo /MD /O2 -c -Foext/yaml/scanner.obj -IC:\Program Files\lua/include ext/yaml/scanner.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
scanner.c
cl /nologo /MD /O2 -c -Foext/yaml/yaml.obj -IC:\Program Files\lua/include ext/yaml/yaml.c -DPACKAGE=lyaml -DVERSION=git -DNDEBUG=1 -D_FORTIFY_SOURCE=2 -Ic:\program files\libyaml/include -IC:\Program Files\lua/include
yaml.c
link -dll -def:yaml.def -out:yaml.dll C:\Program Files\lua/lib/lua5.4.lib ext/yaml/emitter.obj ext/yaml/parser.obj ext/yaml/scanner.obj ext/yaml/yaml.obj -libpath:c:\program files\libyaml -libpath:c:\program files\libyaml/bin yaml.lib
Microsoft (R) Incremental Linker Version 14.38.33133.0
Copyright (C) Microsoft Corporation. All rights reserved.
lua5.4.lib(lstate.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
Microsoft (R) Incremental Linker Version 14.38.33133.0
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library yaml.lib and object yaml.exp
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_stream_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_stream_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_document_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_document_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_alias_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_scalar_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_sequence_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_sequence_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_mapping_start_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_mapping_end_event_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_initialize
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_delete
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_set_output
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_set_width
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_set_unicode
emitter.obj : error LNK2001: unresolved external symbol __imp_yaml_emitter_emit
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_event_delete
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_initialize
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_initialize
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_delete
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_delete
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_set_input_string
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_set_input_string
parser.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_parse
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_token_delete
scanner.obj : error LNK2001: unresolved external symbol __imp_yaml_parser_scan
yaml.dll : fatal error LNK1120: 23 unresolved externals
Error: Build error: Failed compiling module yaml.dll
I built libyaml as a static library; installing from luarocks also silently fails the same way when libyaml is built as a .dll.
By default, Lua displays only the 14 digits of a number. For numbers with a precision exceeding 14 decimals, Lua will output them using scientific notation, resulting in a loss of decimal precision. But it can actually represent integers with a precision of 2^53
bits.
I'm getting a "Directory 'doc' not found" error when trying to install 6.1.1. This is on a fresh, relatively simple docker image: https://gist.github.com/mjbryant/3bbb7b41eac91d450b2771b2d896c1e0
When I try install lyaml on Windows I get luke: fatal: cannot find LDocs generator
.
But ldoc installed and i can call it from command line.
Also cmake file for libyaml produce libyaml.lib
and for MS compiler when you define
yaml.lib
it does not lookup libyaml.lib
but only yaml.lib
. So I also have to rename it.
Also to build against static version of libyaml it required define YAML_DECLARE_STATIC
when you build C module.
So I write my rockspec file to support build on MSVC on Windows.
I test it with MSVC 2010/2015
You can checkout file in my repo
Is it possible to create a support to s390x plattaform (mainframe)?
I am trying to install kong in s390x plattaform, and lyaml is a required library that I couldn't install.
When I try to install it gives me the error "luke: fatal: no modules table in 'lukefile', nothing to build". Looking into lukefile, there is no s390x platform, so I believe the error is because of that.
According to http://yaml.org/spec/1.1/current.html section 7.1.1:
Documents with a “YAML” directive specifying a higher minor version (e.g. “%YAML 1.2”) should be processed with an appropriate warning. Documents with a “YAML” directive specifying a higher major version (e.g. “%YAML 2.0”) should be rejected with an appropriate error message.
But actually, if %YAML is specified, and is anything other than 1.1, lyaml always errors out with a incompatible YAML document
error.
This might be a problem in libyaml-0.1.4, or it might be lyaml. Either way... investigation required!
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for specl... /usr/local/bin/specl
checking for ldoc... /usr/local/bin/ldoc
checking for a Lua interpreter with version >= 5.1, < 5.4... lua
checking for lua... /usr/bin/lua
checking for lua version... 5.1
checking for lua platform... unknown
checking for lua script directory... ${prefix}/share/lua/5.1
checking for lua module directory... ${exec_prefix}/lib/lua/5.1
checking for ANSI C header files... (cached) yes
checking if LUA_VERSION is defined... yes
checking lua.h usability... no
checking lua.h presence... no
checking for lua.h... no
checking lualib.h usability... no
checking lualib.h presence... no
checking for lualib.h... no
checking lauxlib.h usability... no
checking lauxlib.h presence... no
checking for lauxlib.h... no
checking luaconf.h usability... no
checking luaconf.h presence... no
checking for luaconf.h... no
configure: error: cannot find Lua includes
When installing the library on OSX, at one point the output says:
libtool: warning: remember to run 'libtool --finish /usr/lib/luarocks/rocks/lyaml/6.0-1/lib/lua/5.1'
Executing this command generates the following error:
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `-' in: --finish
And prevents the library from working:
/usr/local/share/lua/5.1/lub/Autoload.lua:28: module 'yaml.version' not found:
no field package.preload['yaml.version']
no file './yaml/version.lua'
no file '/usr/local/share/lua/5.1/yaml/version.lua'
no file '/usr/local/share/lua/5.1/yaml/version/init.lua'
no file '/usr/local/lib/lua/5.1/yaml/version.lua'
no file '/usr/local/lib/lua/5.1/yaml/version/init.lua'
no file './yaml/version.so'
no file '/usr/local/lib/lua/5.1/yaml/version.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no module 'yaml.version' in file '/usr/local/lib/lua/5.1/yaml.so'
/usr/local/share/lua/5.1/lub/Autoload.lua:28: module 'yaml.emitter' not found:
no field package.preload['yaml.emitter']
no file './yaml/emitter.lua'
no file '/usr/local/share/lua/5.1/yaml/emitter.lua'
no file '/usr/local/share/lua/5.1/yaml/emitter/init.lua'
no file '/usr/local/lib/lua/5.1/yaml/emitter.lua'
no file '/usr/local/lib/lua/5.1/yaml/emitter/init.lua'
no file './yaml/emitter.so'
no file '/usr/local/lib/lua/5.1/yaml/emitter.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no module 'yaml.emitter' in file '/usr/local/lib/lua/5.1/yaml.so'
lua: /usr/local/share/lua/5.1/lyaml.lua:227: attempt to call field 'emitter' (a nil value)
stack traceback:
/usr/local/share/lua/5.1/lyaml.lua:227: in function 'Dumper'
/usr/local/share/lua/5.1/lyaml.lua:252: in function 'dump'
/tmp/test.lua:2: in main chunk
[C]: ?
Using lyaml.load() any empty (flow) mappings and sequences cannot be distinguished in the returned Lua table.
Both will show up as an empty table. With minimum disruption this can be easily fixed by optionally (opts.distinct_sequence) allowing
load_sequence to return {{}} in case of #sequence == 0.
Good day,
I'm reading about nil usage in docs and I wonder whether it's reasonable to have a parameter to lyaml.load()
function that will make it load null values as nil
.
My yamls are usually config files, so they do not have null keys. I would rather prefer for downstream code that uses loaded config to use it simply as table - today it has to assume it's lyaml table for null detection.
What do you think?
I was wondering if it would be possible to add a flag to sort keys in arrays before generating?
Hi, could you help to check this issue?
I have installed the latest version of libYAML
at: https://pyyaml.org/wiki/LibYAML
After that, I try to install lyaml
by using luarocks
:
luarocks install lyaml YAML_DIR=$LOCAL_SOFTWARE/libyaml
But the error was thrown as below:
Installing https://luarocks.org/lyaml-6.2.3-1.src.rock
/home/bcpe/software/openresty/luajit/bin/luajit build-aux/luke package="lyaml" version="6.2.3" \
PREFIX="/home/bcpe/software/luarocks/lib/luarocks/rocks/lyaml/6.2.3-1" \
CFLAGS="-O2 -fPIC" LIBFLAG="-shared" LIB_EXTENSION="so" OBJ_EXTENSION="o" \
LUA="/home/bcpe/software/openresty/luajit/bin/luajit" \
LUA_DIR="/home/bcpe/software/luarocks/lib/luarocks/rocks/lyaml/6.2.3-1/lua" \
LUA_INCDIR="/home/bcpe/software/openresty/luajit/include/luajit-2.1" \
YAML_DIR="/home/bcpe/software/libyaml" \
YAML_INCDIR="/home/bcpe/software/libyaml/include" \
YAML_LIBDIR="/home/bcpe/software/libyaml/lib"
luke: fatal: required symbol 'yaml_document_initialize' not found in any of libc, libyaml
Error: Build error: Failed building.```
plain_implicit
and quoted_implicit
on the following line https://github.com/gvvaughan/lyaml/blob/master/ext/yaml/emitter.c#L256 do not actually get set, though it should be set from the values in lua.
You do use these on these in lyaml at
https://github.com/gvvaughan/lyaml/blob/master/lib/lyaml/init.lua#L154-L155
I found this while making my own dumper using the emitter and could not emit tags for scalars.
If you would like I can make a pull request to fix this. PR: #37
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.