microsoft / vscode

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

`--extensions-dir` option to `code` cli ignored in 1.74.0 #169035

Closed pokey closed 1 year ago

pokey commented 1 year ago

Type: Bug

Steps to reproduce

  1. Make sure you have an extension installed in VSCode (any extension)
  2. Run mkdir foo to make an empty directory
  3. Run mkdir bar to make an empty directory
  4. Run code --extensions-dir foo bar to open directory bar in VSCode using the empty directory foo as the extensions dir
  5. Run "Extensions: Show Enabled Extensions" command from the command palette in the newly opened workspace

Expected behaviour

There should be no extensions in the list, because code was called with an empty extensions dir

Actual behaviour

It shows the full list of extensions from the default extension dir. Also, I can confirm that these extensions are actually activated (ie not just displayed in the list)

Notes

System info

VS Code version: Code 1.74.0 (5235c6bb189b60b01b1f49062f4ffa42384f8c91, 2022-12-05T16:43:37.594Z) OS version: Darwin x64 21.5.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 2, 2| |Memory (System)|32.00GB (4.14GB free)| |Process Argv|--crash-reporter-id 99d35f96-61a9-461b-a60d-f915d32f3eee| |Screen Reader|no| |VM|0%|
Extensions (102) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 Bookmarks|ale|13.3.1 tsl-problem-matcher|amo|0.6.2 andreas-talon|And|3.0.0 vscode-neovim-hacked|asv|0.0.85 agda-mode|ban|0.3.11 markdown-checkbox|bie|0.4.0 markdown-mermaid|bie|1.16.0 mermaid-markdown-syntax-highlighting|bpr|1.5.0 vscode-tailwindcss|bra|0.9.1 turbo-console-log|Cha|2.6.2 path-intellisense|chr|2.8.3 regex|chr|0.4.0 doxdocgen|csc|1.4.0 vscode-eslint|dba|2.2.6 vscode-dash|dee|2.4.0 dendron-markdown-shortcuts|den|0.12.1 chmod|dle|1.1.1 githistory|don|0.6.19 xml|Dot|2.5.1 viml|dun|0.1.7 gitlens|eam|13.1.1 EditorConfig|Edi|0.16.4 prettier-vscode|esb|9.10.3 shell-format|fox|7.2.2 remotehub|Git|0.48.0 vscode-pull-request-github|Git|0.56.0 mdmath|goe|2.7.4 vscode-graphql|Gra|0.8.4 vscode-graphql-execution|Gra|0.1.6 vscode-graphql-syntax|Gra|1.0.5 rest-client|hum|0.25.1 elixir-ls|Jak|0.12.0 better-cpp-syntax|jef|1.17.2 cmake-language-support-vscode|jos|0.0.7 jq-syntax-highlighting|jq-|0.0.2 vscode-tree-sitter-query|jri|0.0.1 bash-ide-vscode|mad|1.22.0 syntax-project-pbxproj|mar|0.1.3 rainbow-csv|mec|3.5.0 git-graph|mhu|1.30.0 vscode-edits-history|mis|0.1.6 lalrpop-highlight|mnx|0.0.1 vscode-talonscript|mro|0.3.13 vscode-docker|ms-|1.23.2 csharp|ms-|1.25.2 vscode-dotnet-runtime|ms-|1.6.0 black-formatter|ms-|2022.7.13271013 isort|ms-|2022.9.13271012 python|ms-|2022.20.1 vscode-pylance|ms-|2022.12.21 jupyter|ms-|2022.11.1003412109 jupyter-keymap|ms-|1.0.0 jupyter-renderers|ms-|1.0.12 vscode-jupyter-cell-tags|ms-|0.1.6 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.266.1 remote-ssh|ms-|0.94.0 remote-ssh-edit|ms-|0.84.0 azure-repos|ms-|0.24.0 cmake-tools|ms-|1.12.27 cpptools|ms-|1.13.7 cpptools-extension-pack|ms-|1.3.0 remote-explorer|ms-|0.0.3 remote-repositories|ms-|0.26.0 vscode-github-issue-notebooks|ms-|0.0.128 vsliveshare|ms-|1.0.5788 vsliveshare-audio|ms-|0.1.91 vscode-react-native|msj|1.10.0 vscode-paste-image|mus|1.0.4 java-prettier-formatter|mwp|0.1.5 autodocstring|njp|0.6.1 angular-console|nrw|17.27.1 command-server|pok|0.8.2 cursorless|pok|0.26.522 git-branchless|pok|0.0.1 parse-tree|pok|0.24.0 ruby|reb|0.28.1 LiveServer|rit|5.7.9 format-code-action|roh|0.1.0 rust-analyzer|rus|0.3.1317 multi-command|ryu|1.6.0 scala|sca|0.5.6 metals|sca|1.20.0 vscode-scheme|sjh|0.4.0 vscode-fileutils|sle|3.5.0 sourcery|sou|1.0.1 rewrap|stk|1.16.3 vscode-open-in-github|sys|1.17.0 even-better-toml|tam|0.19.0 rest-book|tan|6.2.1 vscode-lua|tri|0.12.4 cmake|twx|0.0.17 commands|use|1.6.0 intellicode-api-usage-examples|Vis|0.2.6 vscodeintellicode|Vis|1.2.29 vscodeintellicode-completions|Vis|1.0.20 vscode-icons|vsc|12.0.1 vscode-alternate-file|wil|0.3.1 vscode-ruby|win|0.28.0 JavaScriptSnippets|xab|1.8.0 type-challenges|YRM|1.10.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vscaac:30438847 vsclangdf:30486550 c4g48928:30535728 dsvsc012cf:30540253 azure-dev_surveyone:30548225 pyindex848cf:30577861 nodejswelcome1cf:30587006 3biah626:30602489 gswce1:30612156 iaj6b796:30613358 dbltrim-noruby:30604474 f6dab269:30613381 fim-prod:30623723 vscsbc:30628655 ```
sandy081 commented 1 year ago

I am not able to reproduce this. May I know if you have enabled profiles in stable?

pokey commented 1 year ago

Strange. I do not have profiles enabled; here are my settings in case helpful https://github.com/pokey/dotfiles/blob/d9103190ac6bc32fcb1a5b875c242b3a0feeebf6/vscode/settings.json

sandy081 commented 1 year ago

By any chance, you have extensions.json file in the same directory as settings.json ?

rtpt-alexanderneumann commented 1 year ago

Hey, I'm having the same issue here, running on Debian Linux. On 1.73.1 it worked, on 1.74.1 it feels like --extensions-dir is ignored. Running code --extensions-dir [...] gives me an empty list of installed extensions.

This command returns an empty list for 1.74.1, and on 1.73.1 it lists the extensions:

$ code --extensions-dir /usr/share/vscode-extensions --list-extensions

Before, vscode was used to install the extensions to this directory, via:

$ code --extensions-dir /usr/share/vscode-extensions --install-extension <ext>
pokey commented 1 year ago

By any chance, you have extensions.json file in the same directory as settings.json ?

Nope

jeswr commented 1 year ago

Having same issue on 1.74.1. Observed on all of the following OS'

jeswr commented 1 year ago

I've created a minimal repo to demonstrate the issue in my case of extension development.

This repo consists of the default boilerplate for a vscode extension generated using these instructions with the following changes to specify the extensions dir.

I would expect that when I startup the extension development host using the shortcut fn+f5; that the host would not contain any extensions due to the fact that I have set the --extensions-dir to the empty directory at ./vscode-test/extensions/ in the launch.json config. Instead all of my personal extensions appear in the development environment. Furthermore; if I manually install additional extensions to ./vscode-test/extensions/ they do not appear in the extensions development host.

sandy081 commented 1 year ago

@pokey @rtpt-alexanderneumann Can you please try following steps and see if it fixes for you?

@jeswr I think you are having a different issue related to debug launches. Please file a separate issue.

pokey commented 1 year ago

Didn't seem to help: I deleted both files and am still seeing the same issue

sandy081 commented 1 year ago

@pokey Can you please re-describe the problem you are seeing and what steps you are following?

pokey commented 1 year ago

See the description from the top of the issue for steps to reproduce the issue. But basically the code command is ignoring the --extensions-dir option. It should use the directory passed into that option, instead of the normal extensions dir, but it does not. It launches with the same extensions activated as if you hadn't passed the flag

sandy081 commented 1 year ago

It does for me. I tried following:

code --extensions-dir ~/work/testing/setup/extensions-dir --verbose

And I can see code launched with different extensions dir as shown in the main log

Screenshot 2022-12-20 at 19 58 36

Can you please try the same and share the log?

Chaos-070799 commented 1 year ago

I'm here sorry I got tied up with a few other things I am NEW to this and it is a learning process trying to catch all the fine line details in between! I am currently branching into my own part of merchandising so this part is new to me!

rtpt-alexanderneumann commented 1 year ago

@sandy081 Removing both files (.init-default-profile-extensions and extensions.json) fixes it. VSCode creates both files anew.

I've diffed the content of extensions.json and I can see that the paths contained for each extension are different. Before (non-working), the paths were incorrect (pointing to a temporary directory that I used to install the extensions). After, the paths are correct.

In previous versions of VSCode, there was no extensions.json in that directory. In newer versions, VSCode insists on writing one, and fails if it cannot do that (as it is for our directory):

$ code --extensions-dir /usr/share/vscode-extensions --list-extensions
Unable to write file '/usr/share/vscode-extensions/extensions.json' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/usr/share/vscode-extensions/extensions.json')

Our solution (for now) is to make sure that the paths in extensions.json are correct.

Why is it now necessary that VSCode has an extensions.json file? It wasn't before...

Reproducible example:

$ mkdir /tmp/extdir

$ code --extensions-dir /tmp/extdir --install-extension golang.go
[...]
Extension 'golang.go' v0.37.0 was successfully installed.

$ code --extensions-dir /tmp/extdir --list-extensions
golang.go

$ mv /tmp/extdir /tmp/other-extdir

$ code --extensions-dir /tmp/other-extdir --list-extensions
[empty]

$ jq . /tmp/other-extdir/extensions.json
[
  {
    "identifier": {
      "id": "golang.go",
      "uuid": "d6f6cfea-4b6f-41f4-b571-6ad2ab7918da"
    },
    "version": "0.37.0",
    "location": {
      "$mid": 1,
      "fsPath": "/tmp/extdir/golang.go-0.37.0",
      "path": "/tmp/extdir/golang.go-0.37.0",
      "scheme": "file"
    },
    "metadata": {
      "id": "d6f6cfea-4b6f-41f4-b571-6ad2ab7918da",
      "publisherId": "dbf6ae0a-da75-4167-ac8b-75b4512f2153",
      "publisherDisplayName": "Go Team at Google",
      "targetPlatform": "undefined",
      "isApplicationScoped": false,
      "updated": false,
      "isPreReleaseVersion": false,
      "installedTimestamp": 1671619270536,
      "preRelease": false
    }
  }
]

# fix paths
$ sed -i 's,/tmp/extdir,/tmp/other-extdir,g' /tmp/other-extdir/extensions.json

# works again:
$ code --extensions-dir /tmp/other-extdir --list-extensions
golang.go

# remove the files and make the dir r/o
$ rm /tmp/other-extdir/extensions.json /tmp/other-extdir/.init-default-profile-extensions
$ chmod u-w /tmp/other-extdir

$ code --extensions-dir /tmp/other-extdir --list-extensions
Unable to write file '/tmp/other-extdir/extensions.json' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/tmp/other-extdir/extensions.json')
pokey commented 1 year ago

Can you please try the same and share the log?

➜ code --extensions-dir .vscode-sandbox/extensions --verbose ~/vscode-test 
[main 2022-12-21T12:32:44.838Z] [File Watcher (node.js)] Request to start watching: /Users/pokey/Library/Application Support/Code/User (excludes: <none>, includes: <all>),/Users/pokey/Library/Application Support/Code/User/settings.json (excludes: <none>, includes: <all>)
[main 2022-12-21T12:32:44.855Z] Sending env to running instance...
[main 2022-12-21T12:32:44.858Z] [File Watcher (node.js)] correcting a path to watch that seems to be a symbolic link or wrong casing (original: /Users/pokey/Library/Application Support/Code/User/settings.json, real: /Users/pokey/pokey-home-files/vscode/settings.json)
[main 2022-12-21T12:32:44.861Z] [File Watcher (node.js)] Started watching: '/Users/pokey/pokey-home-files/vscode/settings.json'
[main 2022-12-21T12:32:44.863Z] [File Watcher (node.js)] Started watching: '/Users/pokey/Library/Application Support/Code/User'
[main 2022-12-21T12:32:44.907Z] Sent env to running instance. Terminating...
[main 2022-12-21T12:32:44.907Z] Lifecycle#kill()
[main 2022-12-21T12:32:44.907Z] Lifecycle#onWillShutdown.fire()

Note that this was after removing extensions.json and .init-default-profile-extensions from .vscode-sandbox/extensions (the extensions dir). It's a bit odd that it logs no args payload at all 🤔

Strangely, as mentioned above, when I pass the same extensions dir alongside --list-extensions, it lists the correct extensions, and logs the correct extensions-dir:

Command output ``` ➜ code --extensions-dir .vscode-sandbox/extensions --list-extensions --verbose TRACE [File Watcher (node.js)] Request to start watching: /Users/pokey/Library/Application Support/Code/User (excludes: , includes: ),/Users/pokey/Library/Application Support/Code/User/settings.json (excludes: , includes: ) INFO CLI main { _: [], diff: false, merge: false, add: false, goto: false, 'new-window': false, 'reuse-window': false, wait: false, help: false, 'extensions-dir': '.vscode-sandbox/extensions', 'list-extensions': true, 'show-versions': false, 'pre-release': false, version: false, verbose: true, status: false, 'prof-startup': false, 'no-cached-data': false, 'prof-v8-extensions': false, 'disable-extensions': false, 'disable-gpu': false, 'ms-enable-electron-run-as-node': false, telemetry: false, debugRenderer: false, 'enable-smoke-test-driver': false, logExtensionHostCommunication: false, 'skip-release-notes': false, 'skip-welcome': false, 'disable-telemetry': false, 'disable-updates': false, 'disable-keytar': false, 'disable-workspace-trust': false, 'disable-crash-reporter': false, 'skip-add-to-recently-opened': false, 'unity-launch': false, 'open-url': false, 'file-write': false, 'file-chmod': false, force: false, 'do-not-sync': false, trace: false, 'force-user-env': false, 'force-disable-user-env': false, 'open-devtools': false, '__enable-file-policy': false, 'enable-coi': false, 'no-proxy-server': false, 'no-sandbox': false, nolazy: false, 'force-renderer-accessibility': false, 'ignore-certificate-errors': false, 'allow-insecure-localhost': false, 'disable-dev-shm-usage': false, 'profile-temp': false, logsPath: '/Users/pokey/Library/Application Support/Code/logs/20221221T123658' } DEBUG ComputeTargetPlatform: darwin-x64 TRACE Started scanning user extensions r { scheme: 'file', authority: '', path: '/Users/pokey/src/cursorless/.vscode-sandbox/extensions/extensions.json', query: '', fragment: '', _formatted: null, _fsPath: null } TRACE [File Watcher (node.js)] Request to start watching: /Users/pokey/src/cursorless/.vscode-sandbox/extensions (excludes: , includes: ),/Users/pokey/src/cursorless/.vscode-sandbox/extensions/extensions.json (excludes: , includes: ) TRACE Started scanning user extensions r { scheme: 'file', authority: '', path: '/Users/pokey/src/cursorless/.vscode-sandbox/extensions', query: '', fragment: '', _formatted: null, _fsPath: '/Users/pokey/src/cursorless/.vscode-sandbox/extensions' } TRACE [File Watcher (node.js)] correcting a path to watch that seems to be a symbolic link or wrong casing (original: /Users/pokey/Library/Application Support/Code/User/settings.json, real: /Users/pokey/pokey-home-files/vscode/settings.json) TRACE [File Watcher (node.js)] Started watching: '/Users/pokey/pokey-home-files/vscode/settings.json' TRACE [File Watcher (node.js)] Started watching: '/Users/pokey/Library/Application Support/Code/User' TRACE [File Watcher (node.js)] Started watching: '/Users/pokey/src/cursorless/.vscode-sandbox/extensions' TRACE [File Watcher (node.js)] Started watching: '/Users/pokey/src/cursorless/.vscode-sandbox/extensions/extensions.json' TRACE Scanned user extensions: 18 DEBUG ComputeTargetPlatform: darwin-x64 TRACE Scanned user extensions: 17 elmTooling.elm-ls-vscode fwcd.kotlin hbenl.vscode-test-explorer JakeBecker.elixir-ls jrieken.vscode-tree-sitter-query mrob95.vscode-talonscript ms-toolsai.jupyter ms-toolsai.jupyter-keymap ms-toolsai.jupyter-renderers ms-vscode.test-adapter-converter pokey.command-server pokey.parse-tree pokey.talon scala-lang.scala scalameta.metals sleistner.vscode-fileutils usernamehw.commands ```
sandy081 commented 1 year ago

@rtpt-alexanderneumann Using extensions.json now is an implementation detail to support the new upcoming feature profiles - #116740. Your issue of hardcoded paths is fixed in our latest insiders here - https://github.com/microsoft/vscode/issues/169006. This fix will be available in our next release.

sandy081 commented 1 year ago

@pokey Do you have vscode running while you execute this command?

code --extensions-dir .vscode-sandbox/extensions --verbose ~/vscode-test

pokey commented 1 year ago

Yes I run it from the integrated terminal. The same issue also occurs when I run VSCode from a launch config (the issue described in https://github.com/microsoft/vscode/issues/169734)

sandy081 commented 1 year ago

OK. As mentioned in the issue #169734, this was working by chance before. Extensions UI and Running Extensions are completely disconnected because both of them are using two different extensions directories. For this use case, I would recommend to start using our new Profiles feature so that it works flawlessly unlike before -https://code.visualstudio.com/updates/v1_71#_settings-profiles

pokey commented 1 year ago

I can confirm that settings profiles solve the issue for me. Thanks!