CatalaLang / catala

Programming language for literate programming law specification
https://catala-lang.org
Apache License 2.0
1.97k stars 78 forks source link

clerk behavior differs when using absolute or relative paths? #693

Open rprimet opened 1 week ago

rprimet commented 1 week ago

Hi,

Not sure whether it's a bug, just a behavior that I would like more context on and possibly a discussion? : running clerk run with a file yields a different behavior when the target file path is absolute or relative.

For instance, in catala-language-server:

(absolute path)

romain@enclume:~/inria/cat_root/catala-language-server$ clerk run /home/romain/inria/cat_root/catala-language-server/test-case-parser/examples/test_case_arith.catala_en --scope B_test
ninja: error: /tmp/clerk_build_ca1757.ninja:133: unknown target '/home/romain/inria/cat_root/catala-language-server/test-case-parser/examples/test_case_arith.catala_en@interpret'

(relative path)

romain@enclume:~/inria/cat_root/catala-language-server$ clerk run test-case-parser/examples/test_case_arith.catala_en --scope B_test
[5/6] <catala> interpret B_test ⇐ _b...ser/examples/test_case_arith.catala_en
┌─[RESULT]─
│ a = Arith.A { -- w: -4 -- x: 2 -- y: 2 -- z: 4,990.0 }

(if that matters, the clerk.toml file is in the examples direcory in this instance)

AltGr commented 6 days ago

This is indeed a limitation of Ninja: the "key" identifying a target is a specific PATH, without resolution of the underlying file of any kind. I admit it's a sane default though.

What we could attempt to do is some resolution of file names specified on the command-line before we call Ninja from Clerk, though.