Skip to content

Creating source code tarball fails due to use of absolute path #47

@nwhetsell

Description

@nwhetsell

Commit cd7cd64 changed the creation of the source code tarball to use this definition of src_dir:

: "$(dirname "$grammar")"; : "${_/\./}"; src_dir="$_${_:+/}src"

I am by no means a Bash expert, but what seems to be happening is:

  1. $grammar (defined in an enclosing while loop) is passed to dirname and expanded in a string. The resulting string will usually—but not always—be the current folder . (because most Tree-sitter grammars have a grammar.js file in their top-level folder). In some grammars (like TypeScript), the resulting string will be a subfolder of the current folder (like ./tsx or ./typescript).

  2. The special Bash variable _ is expanded in a string using ${parameter/pattern/string} expansion. The effect is to remove periods from the result of $(dirname "$grammar"). For grammars like TypeScript, the result is /tsx or /typescript (without leading periods).

  3. The variable src_dir is assigned the value formed by concatenating:

    • the Bash variable _ (which is now /tsx or /typescript)
    • the path separator / (unless _ is null or unset)
    • src

The result is that, for grammars like TypeScript, src_dir is an absolute path (/tsx/src or /typescript/src). This causes the release action to fail for similarly-formed grammars:

https://github.com/nwhetsell/tree-sitter-lilypond/actions/runs/19333509263/job/55302233936#step:8:22

(The TypeScript grammar was last updated in Nov 2024, well before commit cd7cd64 (Aug 2025), so this issue hasn’t had an opportunity to occur there yet.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions