Skip to content

Support extension debugging in a clean environment #159572

Closed

Description

In order to develop and debug extensions in a "clean environment", that means with a clean (or empty) set of extensions and settings, some users tried to use the --extensions-dir and --user-data-dir command line options in their extension's debug configuration.

Since this does not work, issues #126737 and #130504 were created.
Fixing these issues is difficult and would result in large and high-risk code changes.

With the recent work on "settings profiles", a much simpler solution is in reach.

This feature request will make profiles available for extension debugging in a clean environment.

Activity

  1. added
    feature-request
    debug
    on Aug 30, 2022
  2. weinand commented on Aug 30, 2022

    @weinand
    ContributorAuthor

    With the "settings profile" feature and the new command line support for profiles it is now possible to specify profiles in the extension's debug configuration.

    There are basically two possible approaches:

    • "debugging in a clean environment" by using an unnamed "empty" profile that gets automatically deleted when debugging has stopped.
    • "debugging in a controlled environment" by using a named profile that has been created specifically for extension debugging and contains specific settings and extensions.

    This debug configuration shows how to "debug in a clean environment":

    {
        "name": "Extension",
        "type": "extensionHost",
        "request": "launch",
        "args": [
            "--profile-temp",
            "--extensionDevelopmentPath=${workspaceFolder}",
            "${workspaceFolder}/sampleWorkspace"
        ],
        "outFiles": [
            "${workspaceFolder}/dist/**/*.js"
        ],
        "preLaunchTask": "npm: watch"
    }

    Please note: the configuration from above passes a workspace folder ${workspaceFolder}/sampleWorkspace which is currently mandatory for the --profile-temp option. If the workspace folder argument is missing, the --profile-temp option is silently ignored. We will try to remove this requirement soon (see issue #159577).

    And here is a debug configuration for "debugging in a controlled environment" that uses a previously created "debug" profile:

    {
        "name": "Extension",
        "type": "extensionHost",
        "request": "launch",
        "args": [
            "--profile=debug",
            "--extensionDevelopmentPath=${workspaceFolder}"
        ],
        "outFiles": [
            "${workspaceFolder}/dist/**/*.js"
        ],
        "preLaunchTask": "npm: watch"
    }
  3. weinand commented on Sep 8, 2022

    @weinand
    ContributorAuthor

    With the fix for #159577 here is now an up-to-date description of the feature:


    With the "settings profile" feature and the new command line support for profiles it is now possible to specify profiles in the extension's debug configuration.

    There are basically two possible approaches:

    • "debugging in a clean environment" by using an unnamed "empty" profile that gets automatically deleted when debugging has stopped.
    • "debugging in a controlled environment" by using a named profile that has been created specifically for extension debugging and contains specific settings and extensions.

    This debug configuration shows how to "debug in a clean environment":

    {
        "name": "Extension",
        "type": "extensionHost",
        "request": "launch",
        "args": [
            "--profile-temp",
            "--extensionDevelopmentPath=${workspaceFolder}"
        ],
        "outFiles": [
            "${workspaceFolder}/dist/**/*.js"
        ],
        "preLaunchTask": "npm: watch"
    }

    And here is a debug configuration for "debugging in a controlled environment" that uses a previously created "debug" profile:

    {
        "name": "Extension",
        "type": "extensionHost",
        "request": "launch",
        "args": [
            "--profile=debug",
            "--extensionDevelopmentPath=${workspaceFolder}"
        ],
        "outFiles": [
            "${workspaceFolder}/dist/**/*.js"
        ],
        "preLaunchTask": "npm: watch"
    }

    Please note:
    when using --profile-temp for debugging an extension in a remote location (via one of the "Remote Development" extensions, e.g. "Remote - SSH"), the remote VS Code instance will show this status message:

    2022-09-08_11-46-47
    This is expected because the temporary profile does not include any extensions which means that the "Remote Development" extensions are missing. The workaround is to create an empty named profile, add the "Remote Development" extensions to it, and use the --profile=.... command line option.

  4. locked and limited conversation to collaborators on Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debugextensions-developmentfeature-requeston-testplan

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions