1

I have cloned grafonnet-lib from https://github.com/grafana/grafonnet-lib link and created a sample jsonnet file to convert it to json that grafana can read. But when I run the command "jsonnet -J /Data/Perf_Tool/grafonnet-lib/ sample.jsonnet" I get "Opening input file: sample.jsonnet: No such file or directory" Error. I have cloned grafonnet-lib project into /Data/Perf_Tool/grafonnet-lib/ directory and sample.jsonnet file is created on the same directory.

root@hostname:/Data/Perf_Tool/grafonnet-lib# jsonnet -J /Data/Perf_Tool/grafonnet-lib/ sample.jsonnet 
Opening input file: sample.jsonnet: No such file or directory

Content of sample.jsonnet

local grafana = import 'grafonnet/grafana.libsonnet';
local dashboard = grafana.dashboard;
local text = grafana.text;
dashboard.new('My Cool Dashboard')
.addPanel(
 text.new(
 title="Oh Hi",
 content="Welcome to my dashboard.",
 ),
 gridPos={x: 0, y: 0, w: 24, h: 10},
)

Please let me know what I am missing.

Vinod JV
  • 13
  • 3

1 Answers1

2

I think you have to provide the full path of the jsonnet file like this:

jsonnet -J /Data/Perf_Tool/grafonnet-lib/ /Data/Perf_Tool/sample.jsonnet
  • 1
    For completeness: the file provided here as an the entry point is not imported, but naively read by the `jsonnet` command, before any evaluation. The `-J` option does not affect it at all. It does not have to be an absolute path - a path relative to current working directory would work just as well. On the other hand, paths passed through `--tla-code-file` and such are imported, and therefore affected by Jsonnet library path (`-J` option). – sbarzowski Nov 26 '19 at 11:10