microsoft / vscode

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

Portable version of VSCode uses absolute path for location entry in data\extensions\extensions.json #210411

Open daixtrose opened 7 months ago

daixtrose commented 7 months ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Unzip the portable version of VSCode to an arbitrary empty directory (e.g. C:\Users\<username>\Downloads\VSCode-win32-x64-1.88.1)
  2. Create a new directory data in this directory, i.e. C:\Users\<username>\Downloads\VSCode-win32-x64-1.88.1\data
  3. Install some extensions
  4. Check the content of the file data\extensions\extensions.json, i.e. C:\Users\<username>\Downloads\VSCode-win32-x64-1.88.1\data\extensions\extensions.json

Expected Behavior

A relocatable configuration file

Actual Behavior

The configuration file contains full paths to the installed extensions. This renders the data directory feature useless for pre-installing stuff, then distributing it to other users, and this is a true PITA.

[
    {
        "identifier": {
            "id": "ms-vscode.remote-explorer",
            "uuid": "11858313-52cc-4e57-b3e4-d7b65281e34b"
        },
        "version": "0.4.3",
        "location": {
            "$mid": 1,
            "path": "/C:/Users/<username>/Downloads/VSCode-win32-x64-1.88.1/data/extensions/ms-vscode.remote-explorer-0.4.3",
            "scheme": "file"
        },
        "relativeLocation": "ms-vscode.remote-explorer-0.4.3",
        "metadata": {
            "id": "11858313-52cc-4e57-b3e4-d7b65281e34b",
            "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false,
            "installedTimestamp": 1713161142173,
            "pinned": false,
            "source": "gallery"
        }
    },
    {
        "identifier": {
            "id": "ms-vscode-remote.vscode-remote-extensionpack",
            "uuid": "23d72dfc-8dd1-4e30-926e-8783b4378f13"
        },
        "version": "0.25.0",
        "location": {
            "$mid": 1,
            "path": "/C:/Users/<username>/Downloads/VSCode-win32-x64-1.88.1/data/extensions/ms-vscode-remote.vscode-remote-extensionpack-0.25.0",
            "scheme": "file"
        },
        "relativeLocation": "ms-vscode-remote.vscode-remote-extensionpack-0.25.0",
        "metadata": {
            "id": "23d72dfc-8dd1-4e30-926e-8783b4378f13",
            "publisherId": "ac9410a2-0d75-40ec-90de-b59bb705801d",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false,
            "installedTimestamp": 1713161142134,
            "pinned": false,
            "source": "gallery"
        }
    },
    ...

Requested Behavior

Remove directory path of extensions.json (i.e. /C:/Users/<username>/Downloads/VSCode-win32-x64-1.88.1/data/extensions/) from all location.path entries and remove the entry relativeLocation

[
    {
        "identifier": {
            "id": "ms-vscode.remote-explorer",
            "uuid": "11858313-52cc-4e57-b3e4-d7b65281e34b"
        },
        "version": "0.4.3",
        "location": {
            "$mid": 1,
            "path": "ms-vscode.remote-explorer-0.4.3",
            "scheme": "file"
        },
        "metadata": {
            "id": "11858313-52cc-4e57-b3e4-d7b65281e34b",
            "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false,
            "installedTimestamp": 1713161142173,
            "pinned": false,
            "source": "gallery"
        }
    },
    {
        "identifier": {
            "id": "ms-vscode-remote.vscode-remote-extensionpack",
            "uuid": "23d72dfc-8dd1-4e30-926e-8783b4378f13"
        },
        "version": "0.25.0",
        "location": {
            "$mid": 1,
            "path": "ms-vscode-remote.vscode-remote-extensionpack-0.25.0",
            "scheme": "file"
        },
        "metadata": {
            "id": "23d72dfc-8dd1-4e30-926e-8783b4378f13",
            "publisherId": "ac9410a2-0d75-40ec-90de-b59bb705801d",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false,
            "installedTimestamp": 1713161142134,
            "pinned": false,
            "source": "gallery"
        }
    },
    ...
sandy081 commented 2 months ago

relativeLocation is what used when loading the extensions and absolute location is not used and of no importance here. So the portable VS Code should show the installed extensions when you move it to different device. Agreed that not storing absolute location in portable mode is clean.