devcontainers / spec

Development Containers: Use a container as a full-featured development environment.
https://containers.dev
Creative Commons Attribution 4.0 International
3.62k stars 234 forks source link

Different behavior using legacy options #296

Open klezm opened 1 year ago

klezm commented 1 year ago

Problem

Using the deprecated properties settings and extensions will overwrite/reset all other user settings and not install any other extensions than defined in the property extensions. Using the properties inside the customizations property will only change the defined settings and install the defined extensions additionally to the user extensions.

Deprecated properties (legacy mode):

"settings": {},
"extensions": ["ms-python.python"]

Current usage of these properties:

"customizations": {
    "vscode": {
        "settings": {},
        "extensions": ["ms-python.python"]
    }
}

The customizations property was discussed in #1.

Proposal

It should be possible to reset any user settings/extensions in customizationsvscodesettings / extensions. Maybe add a property reset:

"customizations": {
    "vscode": {
        "reset": {
            "settings": true,
            "extensions": true,
        }
    }
}
samruddhikhandale commented 1 year ago

Hi 👋

Thanks for opening the issue.

Using the deprecated properties settings and extensions will overwrite/reset all other user settings

@klezm When you say user-settings, are these the one which gets added by the Features?

If that's the case, then I think it seems like a change in behavior is a result of https://containers.dev/implementors/spec/#merge-logic ; where the devcontainers/cli merges the customization property from devcontainer.json and devcontainer-feature.json. The merge logic might not be added to the deprecated extensions & settings property.

If you are looking to turn off all the customizations property, you could use the experimental --skip-persisting-customizations-from-features flag for the devcontainer build command. It omits all the Feature specified customizations ie. if your devcontainer.json referred to a set of Features, then their corresponding customizations (which includes extensions) will not be applied to your dev container.

We also have a similar issue open for opting out of extensions, see https://github.com/devcontainers/features/issues/386

klezm commented 1 year ago

The issue is independent from the features. My guess is that setting extensions but not customizationsvscodeextensions will leave the latter to be [] therefore omitting locally installed vscode extensions. But If you set customizationsvscodeextensions to e.g. ["ms-python.python"] the merge logic of vscode will add that extensions to the locally installed ones.