microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 449 forks source link

SyntaxError: Unexpected token V in JSON at position 0 #254

Closed letmaik closed 6 years ago

letmaik commented 6 years ago

I'm suddenly getting the following error message, probably caused by an update to this extension:

CMakeTools extension was unable to initialize: SyntaxError: Unexpected token V in JSON at position 0 [See output window for more details]

The extension seems to invoke vswhere with an unsupported argument -prerelease. The output of "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -format json -products * -legacy -prerelease on my system is:

Visual Studio Locator version 1.0.62 Copyright (C) Microsoft Corporation. All rights reserved.

Error 0x57: Unknown parameter: prerelease

Without -prerelease the output is:

[
  {
    "instanceId": "...",
    "installDate": "2017-06-20T15:00:38Z",
    "installationName": "VisualStudio/15.2.0+26430.13",
    "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise",
    "installationVersion": "15.0.26430.13",
    "displayName": "Visual Studio Enterprise 2017",
    "description": "Microsoft DevOps solution for productivity and coordination across teams of any size",
    "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
    "channelId": "VisualStudio.15.Release",
    "channelPath": "C:\\Users\\...\\AppData\\Local\\Microsoft\\VisualStudio\\Packages\\_Channels\\4CB340F5\\catalog.json",
    "channelUri": "https://aka.ms/vs/15/release/channel",
    "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660284#15.1.26430.13",
    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660300"
  },
  {
    "instanceId": "VisualStudio.14.0",
    "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\",
    "installationVersion": "14.0"
  }
]
letmaik commented 6 years ago

I updated to VS 15.4 and it works now, but I feel like this should be handled a bit more gracefully.

vector-of-bool commented 6 years ago

There's a -nologo option to VSWhere, but it never seemed to do anything for me (I think newer versions have it implied by -format json). I can just add it for safety's sake.

letmaik commented 6 years ago

How is this related to -nologo?

vector-of-bool commented 6 years ago

I might be wrong. I'm wondering how common this is. I haven't gotten any other reports on it yet, but I'll keep my ears open...

letmaik commented 6 years ago

I think you misunderstood the issue. It's not a problem of JSON or -nologo, it's just that vswhere throws an error message if you give it any unsupported command line arguments, like -prerelease which wasn't supported in older versions. Feel free to close the issue, but maybe it would be good to have a fall-back for older versions, so first try with -prerelease and if that errors, then without it.

JMLX42 commented 6 years ago

Removing -prerelease here : https://github.com/vector-of-bool/vscode-cmake-tools/blob/develop/src/environment.ts#L305

Solves this issue for me. I have both VS2015 and VS2017 installed.

skalldri commented 6 years ago

+1, I just hit this on my machine. Currently on a very limited data connection so I can't try updating the Visual Studio installer at this moment.

vector-of-bool commented 6 years ago

@letmaik, you're right, I misunderstood.

I'll have to have a switch to check what vswhere version it is, or maybe bundle the newer version with the extension so that like this don't happen.

vector-of-bool commented 6 years ago

0.10.4 now bundles vswhere in the extension, so you should see this issue go away. Tell me if it persists. Sorry about the long wait.