sjsonnet
sjsonnet copied to clipboard
std.extVar are resolved as FilePath in windows
Hello, When attempting to load jsonnet/json values via std.extVar(), a stacktrace appear with sjsonnet when running in Windows. The same input files and sjsonnet jar works as expected in other OS as Unix or MacOS.
Reproducer
# example.jsonnet
local x = std.extVar('x');
x
# reproduce.bash
./sjsonnet-0.4.9.jar --ext-code x="6057" example.jsonnet
#gives the following stacktrace in Windows
sjsonnet.Error: Internal Error
at [ApplyBuiltin1].(example.jsonnet:1:21)
at [ValidId x].(example.jsonnet:2:1)
Caused by: java.nio.file.InvalidPathException: Illegal char <<> at index 0: <ext-var x>
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
at java.base/java.nio.file.Path.resolve(Path.java:515)
at os.Path.$div(Path.scala:440)
at sjsonnet.OsPath.$div(OsPath.scala:11)
at sjsonnet.Interpreter.parseVar(Interpreter.scala:43)
at sjsonnet.Interpreter.$anonfun$evaluator$2(Interpreter.scala:49)
at scala.Option.map(Option.scala:242)
at sjsonnet.Interpreter.$anonfun$evaluator$1(Interpreter.scala:49)
at sjsonnet.Std$ExtVar$.evalRhs(Std.scala:544)
at sjsonnet.Evaluator.visitApplyBuiltin1(Evaluator.scala:223)
at sjsonnet.Evaluator.visitExpr(Evaluator.scala:37)
at sjsonnet.Evaluator$$anonfun$visitAsLazy$2.compute(Evaluator.scala:83)
at sjsonnet.Lazy.force(Val.scala:23)
at sjsonnet.Evaluator.visitValidId(Evaluator.scala:88)
at sjsonnet.Evaluator.visitExpr(Evaluator.scala:33)
at sjsonnet.Evaluator.visitLocalExpr(Evaluator.scala:113)
at sjsonnet.Evaluator.visitExpr(Evaluator.scala:45)
at sjsonnet.Interpreter.$anonfun$evaluate$3(Interpreter.scala:90)
at sjsonnet.Interpreter.$anonfun$evaluate$2(Interpreter.scala:77)
at scala.util.Either.flatMap(Either.scala:352)
at sjsonnet.Interpreter.evaluate(Interpreter.scala:88)
at sjsonnet.Interpreter.interpret0(Interpreter.scala:72)
at sjsonnet.SjsonnetMain$.$anonfun$main0$30(SjsonnetMain.scala:139)
at scala.util.Either.flatMap(Either.scala:352)
at sjsonnet.SjsonnetMain$.$anonfun$main0$29(SjsonnetMain.scala:71)
at scala.util.Either.flatMap(Either.scala:352)
at sjsonnet.SjsonnetMain$.main0(SjsonnetMain.scala:66)
at sjsonnet.SjsonnetMain$.main(SjsonnetMain.scala:31)
at sjsonnet.SjsonnetMain.main(SjsonnetMain.scala)
This issue seems to have appeared from sjsonnet 0.4.5. By running the same reproducer but using sjsonnet-0.4.4 no issues are identified:
$ ./sjsonnet-0.4.4.jar --ext-code x="6057" example.jsonnet
6057