errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.45k stars 153 forks source link

Dictionaries in `dicpath` cannot be symlinks #592

Closed eskwayrd closed 1 year ago

eskwayrd commented 1 year ago

vale 2.24.0 macOS Ventura 13.2.1 on an M1 Max.

I'm attempting to use Vale for documentation in a Node.js project. I have several NPM packages that install dictionaries, which means that the dictionaries don't exist in a single folder.

In my project, I created a new folder dictionaries and then created symlinks inside that folder to the dictionaries in the NPM packages. Then I configured my Spelling style with dicpath: dictionaries. When I run vale, it crashes:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0xb8 pc=0x1030ccd44]

goroutine 12 [running]:
github.com/errata-ai/vale/v2/internal/spell.(*goSpell).inputConversion(...)
    /home/runner/work/vale/vale/internal/spell/gospell.go:40
github.com/errata-ai/vale/v2/internal/spell.(*Checker).Convert(0x12a8abfff?, {0x140005b87e0?, 0x14001c08be8?})
    /home/runner/work/vale/vale/internal/spell/multi.go:152 +0x84
github.com/errata-ai/vale/v2/internal/check.Spelling.Run({{{{0x0, 0x0}, {0x0, 0x0, 0x0}}, {0x0, 0x0}, {0x140043a4070, 0x8}, {0x140043a4110, ...}, ...}, ...}, ...)
    /home/runner/work/vale/vale/internal/check/spelling.go:147 +0x50
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintBlock(0x14001c097a0, 0x14001b70000, {{0x14001b66000, 0x92bb}, 0x5, {0x1400057c705, 0x9}, {0x140005b87e0, 0x28}}, 0x140005b87e0?, ...)
    /home/runner/work/vale/vale/internal/lint/lint.go:237 +0x178
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintProse(0x14004813718?, 0x14001b70000, {{0x14001b66000, 0x92bb}, 0x5, {0x1032513a5, 0x3}, {0x140005b87e0, 0x28}}, 0x0?)
    /home/runner/work/vale/vale/internal/lint/lint.go:209 +0x154
github.com/errata-ai/vale/v2/internal/lint.Linter.lintScope({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002a506c0, 0x140043a8228, 0x103b230c0, 0x1, ...}, ...)
    /home/runner/work/vale/vale/internal/lint/ast.go:172 +0x12c
github.com/errata-ai/vale/v2/internal/lint.Linter.lintHTMLTokens({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002a506c0, 0x140043a8228, 0x103b230c0, 0x1, ...}, ...)
    /home/runner/work/vale/vale/internal/lint/ast.go:129 +0x664
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintHTML(0x14000044640, 0x14001b70000)
    /home/runner/work/vale/vale/internal/lint/html.go:29 +0xf0
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFile(0x14000044640, {0x1400191bc50?, 0xb645a2f853504e4e?})
    /home/runner/work/vale/vale/internal/lint/lint.go:178 +0x430
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1.1({0x1400191bc50?, 0x1eb852f842560240?})
    /home/runner/work/vale/vale/internal/lint/lint.go:114 +0x4c
created by github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1
    /home/runner/work/vale/vale/internal/lint/lint.go:112 +0x1e8
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0xb8 pc=0x1030ccd44]

goroutine 16 [running]:
github.com/errata-ai/vale/v2/internal/spell.(*goSpell).inputConversion(...)
    /home/runner/work/vale/vale/internal/spell/gospell.go:40
github.com/errata-ai/vale/v2/internal/spell.(*Checker).Convert(0x20?, {0x14003176360?, 0x14001c04c38?})
    /home/runner/work/vale/vale/internal/spell/multi.go:152 +0x84
github.com/errata-ai/vale/v2/internal/check.Spelling.Run({{{{0x0, 0x0}, {0x0, 0x0, 0x0}}, {0x0, 0x0}, {0x140043a4070, 0x8}, {0x140043a4110, ...}, ...}, ...}, ...)
    /home/runner/work/vale/vale/internal/check/spelling.go:147 +0x50
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintBlock(0x14001c057a0, 0x14001e6e000, {{0x1400334e000, 0xd80d}, 0x5, {0x14003156530, 0x9}, {0x14003176360, 0x24}}, 0x14003176360?, ...)
    /home/runner/work/vale/vale/internal/lint/lint.go:237 +0x178
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintProse(0x14001c05718?, 0x14001e6e000, {{0x1400334e000, 0xd80d}, 0x5, {0x1032513a5, 0x3}, {0x14003176360, 0x24}}, 0x0?)
    /home/runner/work/vale/vale/internal/lint/lint.go:209 +0x154
github.com/errata-ai/vale/v2/internal/lint.Linter.lintScope({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002a506c0, 0x140043a8228, 0x103b230c0, 0x1, ...}, ...)
    /home/runner/work/vale/vale/internal/lint/ast.go:172 +0x12c
github.com/errata-ai/vale/v2/internal/lint.Linter.lintHTMLTokens({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0x14002a506c0, 0x140043a8228, 0x103b230c0, 0x1, ...}, ...)
    /home/runner/work/vale/vale/internal/lint/ast.go:129 +0x664
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintHTML(0x14000044640, 0x14001e6e000)
    /home/runner/work/vale/vale/internal/lint/html.go:29 +0xf0
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFile(0x14000044640, {0x14001f8cfc0?, 0x0?})
    /home/runner/work/vale/vale/internal/lint/lint.go:178 +0x430
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1.1({0x14001f8cfc0?, 0x0?})
    /home/runner/work/vale/vale/internal/lint/lint.go:114 +0x4c
created by github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1
    /home/runner/work/vale/vale/internal/lint/lint.go:112 +0x1e8
make: *** [vale] Error 2

The file structure of the dictionaries folder:

$ ls -l dictionaries
total 1744
lrwxr-xr-x  1 eskwayrd  staff      26 23 Mar 16:51 en_US.dic@ -> ../node_modules/dictionary-en/index.dic
lrwxr-xr-x  1 eskwayrd  staff      26 23 Mar 16:51 en_US.aff@ -> ../node_modules/dictionary-en/index.aff
... additional symlinks to more dictionaries ...

If I replace the symlinks with copies of the dictionary files, vale runs successfully.

Supporting symlinks would be great, since I wouldn't have to worry about the copied dictionary files getting out of date should the package dictionaries get updated. Supporting multiple dicpath entries would also work.

jdkato commented 1 year ago

I can reproduce the issue with symlinks not working, but I can't reproduce the crash. Could you share your spelling rule?

jdkato commented 1 year ago

Should be fixed in the next release.