Skip to content

Commit c1183af

Browse files
authored
fix: optionally write to settings (#123)
1 parent 8193a11 commit c1183af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/remote.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ export class Remote {
277277
const parsed = jsonc.parse(settingsContent)
278278
parsed["remote.SSH.remotePlatform"] = remotePlatforms
279279
const edits = jsonc.modify(settingsContent, ["remote.SSH.remotePlatform"], remotePlatforms, {})
280-
await fs.writeFile(this.storage.getUserSettingsPath(), jsonc.applyEdits(settingsContent, edits))
280+
try {
281+
await fs.writeFile(this.storage.getUserSettingsPath(), jsonc.applyEdits(settingsContent, edits))
282+
} catch (ex) {
283+
// The user will just be prompted instead, which is fine!
284+
// If a user's settings.json is read-only, then we can't write to it.
285+
// This is the case when using home-manager on NixOS.
286+
}
281287

282288
const workspaceUpdate = new vscode.EventEmitter<Workspace>()
283289
const watchURL = new URL(`${this.storage.getURL()}/api/v2/workspaces/${this.storage.workspace.id}/watch`)

0 commit comments

Comments
 (0)