GNU bug report logs - #66836
[Patch] gnu: Add tree-sitter-yaml.

Previous Next

Package: guix-patches;

Reported by: Emma Turner <mail <at> emturner.co.uk>

Date: Mon, 30 Oct 2023 16:36:02 UTC

Severity: normal

Tags: moreinfo, patch

Done: Hilton Chain <hako <at> ultrarare.space>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Olivier Rojon <o.rojon <at> posteo.net>
To: 66836 <at> debbugs.gnu.org
Cc: Emma Turner <mail <at> emturner.co.uk>, hako <at> ultrarare.space, Katherine Cox-Buday <cox.katherine.e+guix <at> gmail.com>, Liliana Marie Prikler <liliana.prikler <at> gmail.com>, Andrew Tropin <andrew <at> trop.in>
Subject: [bug#66836] [PATCH v2] gnu: Add tree-sitter-yaml.
Date: Sun, 02 Mar 2025 19:28:11 +0000
Hej fellows,

I've tried for some time to get it packaged but rather quickly hit a road block because I
am simply not well versed in the domain.  Find below the code I managed to come up after a
bit of experimentation.

```
(define-public tree-sitter-yaml
  (tree-sitter-grammar
   "yaml" "YAML"
   "0z5fz9hiafzapi0ijhyz8np6rksq6c1pb16xv1vhnlfh75rg6zyv"
   "0.7.0"
   #:repository-url
   "https://github.com/tree-sitter-grammars/tree-sitter-yaml"))
```

Surprisingly, it started by downloading nodejs 22.10 which didn't happen for other
tree-sitter grammars I tried building for reference.  The build fails in the build phase,
this is the output:

```
starting phase `build'
/tmp/guix-build-tree-sitter-yaml-0.7.0.drv-0/source/grammar.js:674
  for (const [rule_name, rule] of Object.entries(grammar_json.rules)) {
                                                              ^

TypeError: Cannot read properties of undefined (reading 'rules')
    at global_alias (/tmp/guix-build-tree-sitter-yaml-0.7.0.drv-0/source/grammar.js:674:63)
    at Object.<anonymous> (/tmp/guix-build-tree-sitter-yaml-0.7.0.drv-0/source/grammar.js:566:39)
    at Module._compile (node:internal/modules/cjs/loader:1565:14)
    at Object..js (node:internal/modules/cjs/loader:1708:10)
    at Module.load (node:internal/modules/cjs/loader:1318:32)
    at Function._load (node:internal/modules/cjs/loader:1128:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
    at Module.require (node:internal/modules/cjs/loader:1340:12)
    at require (node:internal/modules/helpers:138:16)

Node.js v22.12.0
Node process exited with status 1
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "tree-sitter" arguments: ("generate" "--no-bindings") exit-status: 
phase `build' failed after 0.0 seconds
command "tree-sitter" "generate" "--no-bindings" failed with status 1
build process 18 exited with status 256
builder for `/gnu/store/mhslv5phv7yic1rv91pq4kiqyhkzgvi1-tree-sitter-yaml-0.7.0.drv' failed with exit c
build of /gnu/store/mhslv5phv7yic1rv91pq4kiqyhkzgvi1-tree-sitter-yaml-0.7.0.drv failed
Could not find build log for '/gnu/store/mhslv5phv7yic1rv91pq4kiqyhkzgvi1-tree-sitter-yaml-0.7.0.drv'.
guix build: error: build of `/gnu/store/mhslv5phv7yic1rv91pq4kiqyhkzgvi1-tree-sitter-yaml-0.7.0.drv' fa
```

I also tried building the newest commit from the originally mentioned repository:
https://github.com/ikatyang/tree-sitter-yaml.  This initially looks more promising but
then there is several errors regarding indentation and some other INVALID entries which
also results in a build failure.

I am afraid this is what I have to offer when it comes to trying to support the packaging
endeavour.  Maybe someone of you guys knows more about tree-sitter grammars than I do and
can chime in.

Have a good day,
Olivier

Olivier Rojon <o.rojon <at> posteo.net> writes:

> Hello everyone,
>
> soo.... it has been a while since there has been some activity.  I have checked and
> couldn't find another effort to get tree-sitter-yaml packaged (that is, no duplicates).
>
> Did anyone of you have spare time to look more into this?  I am very intersted to get this
> package into the guix codebase, and it seems there has been more recent activity not only
> in the original repository (https://github.com/ikatyang/tree-sitter-yaml), but even more
> recently, there has been activity in another repository which is a fork of the original
> one (https://github.com/tree-sitter-grammars/tree-sitter-yaml).
>
> I have spent a short amount of time trying to get either of them to package, but that
> didn't result in any tangible results (all attempts failed, I didn't know what the problem
> was, I gave up).
>
> However, I'd be motivated to try to get it done together, so if any of you is on board,
> let's get it on ;-)
>
> Have a good day, fellows :-)
>
> Hilton Chain <hako <at> ultrarare.space> writes:
>
>> Hi Emma,
>>
>> Tests currently fail on aarch64-linux[1], which can be reproduced with
>> `./pre-inst-env guix build tree-sitter-yaml --system=aarch64-linux`.
>>
>> Any ideas?
>>
>> On Sat, 04 Nov 2023 20:22:10 +0800,
>> Hilton Chain wrote:
>>>
>>> From: Emma Turner <mail <at> emturner.co.uk>
>>>
>>> * gnu/packages/patches/tree-sitter-yaml-fix-tests.patch: New file.
>>> * gnu/local.mk (dist_patch_DATA): Register it.
>>> * gnu/packages/tree-sitter.scm (tree-sitter-yaml): New variable.
>>>
>>> Modified-by: Hilton Chain <hako <at> ultrarare.space>
>>> Change-Id: I45a4a843ecee9dfa580eeaa352f1354915f83881
>>> ---
>>>  gnu/local.mk                                  |   1 +
>>>  .../patches/tree-sitter-yaml-fix-tests.patch  | 690 ++++++++++++++++++
>>>  gnu/packages/tree-sitter.scm                  |  15 +
>>>  3 files changed, 706 insertions(+)
>>>  create mode 100644 gnu/packages/patches/tree-sitter-yaml-fix-tests.patch
>>
>> Thanks
>> ---
>> [1]:
>> https://bordeaux.guix.gnu.org/build/206a6c33-c95a-4f7f-8e15-30e7b5662634/log
>>
>> --- expected / +++ actual
>>
>>   1. Spec Example 9.3. Bare Documents:
>>
>>     (stream
>>       (document
>>         (flow_node
>>           (plain_scalar
>>             (string_scalar))))
>>       (comment)
>>       (document)
>>       (document
>>         (block_node
>> +++       (block_scalar)))
>> +++   (MISSING _eof))
>> ---       (block_scalar))))
>>
>>
>>   2. Spec Example 9.5. Directives Documents:
>>
>>     (stream
>>       (document
>>         (yaml_directive
>>           (yaml_version))
>>         (block_node
>>           (block_scalar)))
>> +++   (MISSING _eof))
>> ---   (document
>> ---     (yaml_directive
>> ---       (yaml_version))
>> ---     (comment)))
>>
>>
>>   3. Zero indented block scalar:
>>
>>     (stream
>>       (document
>>         (block_node
>> +++       (block_scalar)))
>> +++   (MISSING _eof))
>> ---       (block_scalar))))
>>
>>
>>   4. Zero indented block scalar with line that looks like a comment:
>>
>>     (stream
>>       (document
>>         (block_node
>> +++       (block_scalar)))
>> +++   (MISSING _eof))
>> ---       (block_scalar))))




This bug report was last modified 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.