From 9aefe61d48adbcb03e81830c960572d32ea9472f Mon Sep 17 00:00:00 2001 From: Danny Kopping Date: Wed, 3 Dec 2025 11:31:03 +0200 Subject: [PATCH] fix(vscode-web): apply settings on every workspace start Previously, settings were only written to settings.json if the file did not already exist. This meant that template changes to the settings variable would never be applied to existing workspaces. Now, Machine settings are always applied on every workspace start, which is the expected behavior for template-controlled settings. Fixes: https://github.com/coder/registry/issues/42 --- registry/coder/modules/vscode-web/README.md | 2 +- registry/coder/modules/vscode-web/run.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/registry/coder/modules/vscode-web/README.md b/registry/coder/modules/vscode-web/README.md index 43b1eb9d..866757fa 100644 --- a/registry/coder/modules/vscode-web/README.md +++ b/registry/coder/modules/vscode-web/README.md @@ -53,7 +53,7 @@ module "vscode-web" { ### Pre-configure Settings -Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settings-json-file) file: +Configure VS Code's [Machine settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settings-json-file) file. These settings are applied on every workspace start, ensuring template-defined settings are always enforced: ```tf module "vscode-web" { diff --git a/registry/coder/modules/vscode-web/run.sh b/registry/coder/modules/vscode-web/run.sh index 57bb760f..2d366a1b 100644 --- a/registry/coder/modules/vscode-web/run.sh +++ b/registry/coder/modules/vscode-web/run.sh @@ -28,12 +28,12 @@ run_vscode_web() { "$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 & } -# Check if the settings file exists... -if [ ! -f ~/.vscode-server/data/Machine/settings.json ]; then - echo "⚙️ Creating settings file..." - mkdir -p ~/.vscode-server/data/Machine - echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json -fi +# Apply/overwrite template-based settings on every start +# Machine settings are always overwritten to apply template changes. +# See: https://github.com/coder/registry/issues/42 +echo "⚙️ Applying VS Code settings..." +mkdir -p ~/.vscode-server/data/Machine +echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json # Check if vscode-server is already installed for offline or cached mode if [ -f "$VSCODE_WEB" ]; then