Description
Describe the bug
parsing yaml files with a leading UTF-8 byte order mark fails.
Note: I expect this is an upstream issue in the serde_yaml
crate. However, there's no way to raise the issue there as the repo has been archived and is no longer maintained.
I have raised an issue in the serde_norway
fork: cafkafk/serde-norway#8
There are best-effort maintenance efforts being done there, with important caveats about long-term committment; perhaps nushell should consider switching to that fork, or consider what else to do about that problem. I didn't find an open issue relating to that directly, or I'd have just added the link above there.
How to reproduce
❯ "id: thing\nfoo: bar" | save --raw test1.yaml
❯ "id: thing\nfoo: bar" | into binary | bytes add 0x[ef bb bf] | save --raw test2.yaml
❯ open test1.yaml
╭─────┬───────╮
│ id │ thing │
│ foo │ bar │
╰─────┴───────╯
❯ open test2.yaml
Error: × Error while parsing as yaml
╭─[entry #8:1:6]
1 │ open test2.yaml
· ─────┬────
· ╰── Could not parse '/tmp/test2.yaml' with `from yaml`
╰────
help: Check out `help from yaml` or `help from` for more options or open raw data with `open --raw '/tmp/test2.yaml'`
Error: nu::shell::unsupported_input
× Unsupported input
╭─[entry #8:1:1]
1 │ open test2.yaml
· ──┬─┬
· │ ╰── value originates from here
· ╰── Could not load YAML: did not find expected <document start> at line 2 column 1
╰────
# a workaround that removes the BOM again
❯ open --raw test2.yaml | decode utf8 | from yaml
╭─────┬───────╮
│ id │ thing │
│ foo │ bar │
╰─────┴───────╯
Expected behavior
parse all my yaml files with just open **/*.yaml
rather than needing to glob **/*.yaml | each { open --raw $in | decode utf8 | from yaml }
Configuration
key | value |
---|---|
version | 0.98.0 |
major | 0 |
minor | 98 |
patch | 0 |
branch | |
commit_hash | |
build_os | linux-x86_64 |
build_target | x86_64-unknown-linux-gnu |
rust_version | rustc 1.80.1 (3f5fd8dd4 2024-08-06) (built from a source tarball) |
cargo_version | cargo 1.80.0 (376290515 2024-07-16) |
build_time | 1980-01-01 00:00:00 +00:00 |
build_rust_channel | release |
allocator | mimalloc |
features | default, sqlite, trash |
installed_plugins |