grafana / grafana/vscode-jsonnet

Can't navigate to an import file on windows

Open
#32 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
86
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Following my success in getting #30 to work on a remote linux, I'm trying to achieve the same by copying the libjsonnet I got from the server and working locally, on a windows 10 PC.

I got some kind of success by Using this configuration:

```json
{
"jsonnet.languageServer.jpath": [
"C:/workspace/tools/libjsonnet"
],
"jsonnet.languageServer.tankaMode": false
}
```

The autocompletion works, but unlike the linux version, I get a warning on the "local" keyword on my first line;

```
local ddb = import 'ddb.docker.libjsonnet';
```

```
RUNTIME ERROR: Undefined external variable: core.env.available
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:42:29-61 thunk <_core_env_available> from <$>
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:376:35-54 thunk from from >>
:1636:21-24 thunk from >
:32:25-26 thunk from >
:32:16-27 function
:1636:9-25 function
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:376:21-55 thunk from >
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:377:33-40 thunk from from >>
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:377:22-41 thunk from >
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:378:5-10 function
...
:1545:21-22 thunk from >
:1545:5-33 function
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:165:9-43 function
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:272:62-148 thunk from >>
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:175:2-9 function
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:272:32-149 thunk from >
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:177:44-50 function
C:\workspace\tools\libjsonnet\ddb.docker.libjsonnet:272:5-150 function
C:\workspace\projects\THE-PROJECT\docker-compose.yml.jsonnet:(9:1)-(99:3) $
During evaluation
```

OK, that might not be a real issue, and I should probably set every `std.extVar` value I plan to use in the extension configuration, that's no my main concern.

When I try to ctrl+click on the file name on that line, it opens an editor to my project root (C:\workspace\projects\THE-PROJECT), with that message:
![image](https://github.com/grafana/vscode-jsonnet/assets/3399355/902eb8e5-67bc-446b-bd5b-1a4472ad3925)

I suspect there is something off with the path handling of windows, but I don't know what to debug. The only thing I get is this:

```
time="2023-08-16T17:16:59+02:00" level=info msg="configuration updated: {ResolvePathsWithTanka:false JPaths:[C:/workspace/tools/libjsonnet] ExtVars:map[] ExtCode:map[] FormattingOptions:{Indent:2 MaxBlankLines:2 StringStyle:1 CommentStyle:1 PrettyFieldNames:true PadArrays:false PadObjects:true SortImports:true UseImplicitPlus:true StripEverything:false StripComments:false StripAllButComments:false} EnableEvalDiagnostics:true EnableLintDiagnostics:false}"
time="2023-08-16T17:17:02+02:00" level=error msg="Hover: error parsing the document"
```

Any idea of what I need to do ?

EDIT: I tried with tanka enabled and disabled (with a full vs code restart in-between) and it behaves in the same way, except that I have a more verbose "unable to identify the project root" with tanka enabled.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue in VS Code using the jsonnet.languageServer.jpath configuration with C:/workspace/tools/libjsonnet and the ddb.docker.libjsonnet import. Start by tracing the hover and Ctrl+click navigation entry points around the reported "Hover: error parsing the document" log. Done means the import opens its file on Windows instead of the project root, without the parsing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.