saem / vscode-nim

Other
180 stars 23 forks source link

Extension not working on Windows with Nim installed via choosenim? #75

Open girvo opened 2 years ago

girvo commented 2 years ago

So I setup Nim v1.6.4 via choosenim and setup your extension. Autocomplete isn't working at all, and Indexing, file count 3 never goes away.

I checked the dev tools, and there are a few errors that the extension is throwing:

workbench.desktop.main.js:1900 [[object Object]]Cannot read property 'length' of null
$onExtensionRuntimeError @ workbench.desktop.main.js:1900
TypeError: Cannot read property 'length' of null
    at add_33556412 (c:\Users\JoshGirvin\.vscode\extensions\nimsaem.nimvscode-0.1.25\out\nimvscode.js:1692:55)
    at ChildProcess.HEX3Aanonymous_1191182874 (c:\Users\JoshGirvin\.vscode\extensions\nimsaem.nimvscode-0.1.25\out\nimvscode.js:6037:13)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:467:12)
    at maybeClose (internal/child_process.js:1048:16)
    at Socket.<anonymous> (internal/child_process.js:439:11)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:467:12)
    at Pipe.<anonymous> (net.js:673:12)

What am I missing? Is something installed incorrectly? The nim tools execute from the command line fine, and they appear to all be there.

girvo commented 2 years ago

To add some more detail, the file that is throwing the error is:

/* line 1969 "/home/saem/Development/nim/nim-for-choosenim/lib/system.nim" */

function add_33556412(x_33556413, x_33556413_Idx, y_33556414) {
    /* line 1976 "/home/saem/Development/nim/nim-for-choosenim/lib/system.nim" */
          if (x_33556413[x_33556413_Idx] === null) { x_33556413[x_33556413_Idx] = []; }
      var off = x_33556413[x_33556413_Idx].length;
      x_33556413[x_33556413_Idx].length += y_33556414.length;
      for (var i = 0; i < y_33556414.length; ++i) {
        x_33556413[x_33556413_Idx][off+i] = y_33556414.charCodeAt(i);
      }
}

Obviously thats the compiled output, but it seems to have an issue with the choosenim setup? This is choosenim-0.8.2 run completely clean, no Nim installed previously, and its on my %PATH% with no issues:

PS C:\Users\JoshGirvin> $Env:Path
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\JoshGirvin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\CLion 2021.3.3\bin;C:\Users\JoshGirvin\.platformio\penv\Scripts;C:\Users\JoshGirvin\.nimble\bin
girvo commented 2 years ago

For those also running into this issue, I solved it by installing Nim and Mingw64 directly from here

I extracted them to C:\ as C;\nim and C:\mingw64 and added C;\nim\bin and C;\mingw64\bin to my PATH -- now it works, after removing choosenim from my system

grumble9684 commented 2 years ago

Thank you for this bug report! I had the same issue with the extension throwing a "Cannot read property 'length' of null" error and moving nim and mingw to C:\ as you described and updating PATH worked for me as well. No idea why!

RSDuck commented 2 years ago

I'm trying to reproduce your issue, but just installing Nim via choosenim doesn't seem to do the trick.

Also judging from the trace the issue seems to be that nimsuggest crashed in some form, and then the handler which should report that crashes as well, because it doesn't seem to properly handle null values (though the documentation doesn't say anything that??).

RSDuck commented 2 years ago

I could get those null values as well, though only by replacing my nimsuggest executable throw something which always quits with code 1. With #76 this isn't solved, it should just error a bit more gracefully with a proper message and the exit code.

So what's left with this issue is to figure out why nimsuggest exits. The extension should repeat every message nimsuggest puts onto stdout and stderr, is there anything you can see there?

daddycocoaman commented 2 years ago

I was able to solve this by just adding mingw64\bin and nim-1.6.X\bin to my PATH. This just means that every nim update done through choosenim would need another PATH change.