Compare commits

...

1 Commits

Author SHA1 Message Date
Danny Kopping
9aefe61d48 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
2025-12-03 11:31:03 +02:00
2 changed files with 7 additions and 7 deletions

View File

@ -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" {

View File

@ -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..."
# 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
fi
# Check if vscode-server is already installed for offline or cached mode
if [ -f "$VSCODE_WEB" ]; then