The configuration options placed in devcontainer.json not getting picked

Here is the config I used:

{
    "name": "Dev Container Definition - AWS CDK",
    "image": "jsii/superchain",
    "postCreateCommand": "yarn build --skip-test --no-bail --skip-prereqs --skip-compat",
    "extensions": [
        "dbaeumer.vscode-eslint@2.1.5:9Wg0Glx/TwD8ElFBg+FKcQ=="
    ]
}

Here is the codespace for the same: https://ayush987goyal-aws-cdk-g78p.github.dev/

The codespace was not created by the provided image and the postCreateCommand didn’t run as well.

1 Like

Hey! Could you confirm where you’re storing the devcontainer.json file at in your repo? Also, you mentioned that the image and postCreateCommand didn’t work. Did the ESLint extension get installed as expected though?

Hey! The devcontainer.json file is stored in the root of the project. Now that you mentioned it, I noticed that the extension didn’t get installed either. Here is the repo for your reference:

It looks like there’s a small typo in the name of the file. If it’s at the root of the repo, it needs to be called .devcontainer.json with a leading period instead of devcontainer.json. If it’s inside of a .devcontainer folder, then it should be called devcontainer.json without a leading period. I do think this naming convention is confusing though, so you’re probably not the first to run into this issue.

It looks like there’s actually a documentation bug at https://docs.github.com/en/github/developing-online-with-codespaces/configuring-codespaces-for-your-project#about-default-codespace-configurations, which doesn’t show the leading period (@matthewisabel FYI).

Thanks.

  1. Does the postCreateCommand run in background if the codespace is closed/timed-out? (I have seen multiple occurrences where the command didn’t finish and they codespace was disconnected and now there is no way to run the command again or check the logs )

@ayush987goyal, yes the command runs async in the background. It’s not tied to whether you are connected or not. If it’s still running when you are connected, you should see a toast notification letting you know. If you don’t see the toast, or if you reconnect in the future and want to see the logs, you can run the command Codespaces: View Creation Log or view the Codespace in the Remote Explorer viewlet and right click and select View Creation Log.

Thanks a lot @jkeech

@jkeechI have also noticed that:

  1. The creation logs does not update in realtime when view by running the Codespaces: View Creation Log
  2. The extensions get auto-updated even though we mention a specific version in .devcontainer.json
  3. Every time a workspace is created, the extensions are installed based on the user-preferences. Some of these extensions require a reload before which they can be activated. For example, extension like color and icon theme are set in settings but they don’t take effect until after we restart the codespace for extensions to take effect. Could we automatically reload if some preferred extension require them?

@ayush987goyal,

For (1), the logs are supposed to be updating live, unless the scripts are finished. In the case where they are finished, it just shows the output of the log files from when the commands ran. Are you seeing a delay or just not updating at all? Is it possible your script finished or is somehow hanging indefinitely with no output?

For (2), I don’t think pinning the version is supported in devcontainer.json. It always downloads the latest version from the marketplace based on the extension id.

For (3), VS Code is working on getting hot-reload of extensions to work in the web like is already does on the desktop. So in the next month or so that will hopefully work automatically without needing to reload. You can always reload the browser manually today.

It might be easier to start new posts if you run into additional issues so that each post is scoped to a specific problem when other people search for questions/answers :slight_smile: