microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.26k stars 29.3k forks source link

Windows: --user-data-dir argument no longer supports relative paths #120269

Closed FaustVX closed 3 years ago

FaustVX commented 3 years ago

Issue Type: Bug

Since this last update (1.55.0), the argument --user-data-dir is not taken into account anymore.

I use a sortcut on my windows machine, which set --user-data-dir and --extensions-dir arguments, and it worked well up to this last version.

The extensions still works well.

So my settings doesn't "exists" anymore for vscode.

VS Code version: Code 1.55.0 (c185983a683d14c396952dd432459097bc7f757f, 2021-03-30T16:01:55.261Z) OS version: Windows_NT x64 10.0.19042

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.89GB (7.99GB free)| |Process Argv|--extensions-dir .\\.vscode\\Extensions --user-data-dir .\\.vscode\\Data --crash-reporter-id ce3f7bc3-e5a0-4e29-b66f-d9c31d663e22| |Screen Reader|no| |VM|0%|
Extensions (9) Extension|Author (truncated)|Version ---|---|--- arm|dan|1.5.0 gitlens|eam|11.3.0 cortex-debug|mar|0.3.12 remote-ssh|ms-|0.65.1 remote-ssh-edit|ms-|0.65.1 cmake-tools|ms-|1.6.0 cpptools|ms-|1.2.2 hexeditor|ms-|1.4.0 cmake|twx|0.0.17
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 pythonvspyt678:30270856 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstry244:30276681 pythonvsdeb440:30248342 pythonvsded773:30248341 pythonvspyt875:30259475 pythontb:30265425 pythonvspyt943cf:30280190 wslfolderdoc:30282074 vspre833cf:30267465 pythonptprofiler:30281270 vshan820cf:30276953 ```
vscodebot[bot] commented 3 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

FaustVX commented 3 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

No it's not related to debugging.

bpasero commented 3 years ago

I tried this on Windows and macOS and cannot reproduce passing code --user-data-dir <some dir> from the command line.

FaustVX commented 3 years ago

After some testing, it's when the path is relative, the --extensions-dir is relative to current directory, but --user-data-dir is relative to the executable.

With code --extensions-dir .vscode.Extensions --user-data-dir .vscode.Data, the .vscode.Extensions folder is created in the current directory, but .vscode.Data is created in %localappdata%\Programs\Microsoft VS Code\ (where the code.exe is located). And the default directory (without any arguments passed in) is in %appdata%\Code.

And again, everything worked fine in the previous version (1.54.3).

FaustVX commented 3 years ago

In the shortcut file I have, In Target I have: "%localappdata%\Prograams\Microsoft VS Code\Code.exe" --extensions-dir ".\.vscode\Extensions" --user-data-dir ".\.vscode\Data", and in Start In I have: D:\Documents\Development\RpiPico\ (it's the current directory of the lnk file)

FaustVX commented 3 years ago

As a workaround, I put both arguments as absolute path.

But it's not a perfect solution. Also it's not symmetrical between the 2 arguments, and it's a different behavior from previous versions.

bpasero commented 3 years ago

A consequence of https://github.com/microsoft/vscode/commit/1441ba91f0e3fd82ac6860aacda83befe9d176e3 and calling process.chdir very early now:

https://github.com/microsoft/vscode/blob/9cd4712b35237611cd1f9aa92d8fea605b41ebda/src/bootstrap-node.js#L43-L43

We probably need to take the VSCODE_CWD variable into account when resolving the user data path and the provided argument is relative here:

https://github.com/microsoft/vscode/blob/8f1b7a36defa22da806a4af5d208629c9c340251/src/vs/platform/environment/node/userDataPath.js#L44-L44

FaustVX commented 3 years ago

/verified