2

I would really like to try out ksonnet with the VSCode extension but can't seem to get things setup properly and I've read the setup instructions.

I have done the following:

  • brew install ks
  • brew install jsonnet
  • ks init traefik
  • git clone https://github.com/ksonnet/ksonnet-lib.git
  • Edit vscode settings and add ksonnet-lib to settings: "jsonnet.libPaths": ["/Users/kross/projects/gke/ksonnet-lib"],
  • Open the generated traefik folder in a new vscode window (not preferable but wondered about resolution of root path)

Here are the errors I am seeing:

RUNTIME ERROR: couldn't open import "base.libsonnet": no match locally or in the Jsonnet library paths.
Can't find path 'base.libsonnet'. If the file is not in the current directory, it may be necessary to add it to the 'jsonnet.libPaths'. If you are in vscode, you can press 'cmd/ctrl-,' and add the path this library is located at to the 'jsonnet.libPaths' array

enter image description here

NOTE: preview pane does work for ks generate deployed-service file, but preview pane does NOT work for the tutorial redis instance (but ks show default DOES work):

Command failed: jsonnet -J /Users/kross/projects/gke/ksonnet-lib  --ext-code-file "__ksonnet/params"=/Users/kross/projects/gke/traefik/components/params.libsonnet --ext-code-file "__ksonnet/environments"=/Users/kross/projects/gke/traefik/environments/default/params.libsonnet /Users/kross/projects/gke/traefik/components/redis.jsonnet
RUNTIME ERROR: couldn't open import "k.libsonnet": no match locally or in the Jsonnet library paths.
/Users/kross/projects/gke/traefik/components/redis.jsonnet:4:11-31  thunk 
/Users/kross/projects/gke/traefik/components/redis.jsonnet:18:11    thunk 
std.jsonnet:1239:24 
std.jsonnet:1239:15-26  thunk 
std.jsonnet:1240:8  thunk 
std.jsonnet:1240:8-20   function 
std.jsonnet:1240:8-20   function 
/Users/kross/projects/gke/traefik/components/redis.jsonnet:(18:1)-(22:4)    

I must be missing something very fundamental - what is it?

Aleš
  • 8,896
  • 8
  • 62
  • 107
kross
  • 3,627
  • 2
  • 32
  • 60

1 Answers1

3

I had a similar error when using the VScode JSONNET extension. See here: https://github.com/heptio/vscode-jsonnet/issues/57

I was able to fix this by modifying the settings for the extension in User Settings:

"jsonnet.libPaths": [
    "<my-home-dir-full-path>/go/src/github.com/ksonnet/ksonnet-lib/ksonnet.beta.3"
],

Also, note that currently the official ksonnet VSCode extension is under development by the ksonnet team.

Aleš
  • 8,896
  • 8
  • 62
  • 107
  • 1
    Thanks, it's also worth noting that errors will occur if the root folder open in vscode is not the one containing the app.yml (in the case of ksonnet). – kross Aug 08 '18 at 19:01
  • aah, nice! hope ksonnet's extension is out soon. – Aleš Aug 08 '18 at 20:41