From da8e296b1cd425196a8063d2726d5ab2d5b14f11 Mon Sep 17 00:00:00 2001 From: Koury Lape Date: Fri, 20 Mar 2026 11:42:34 -0400 Subject: [PATCH] Fix/dotfiles fish compatibility (#682) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description The dotfiles module does not work when using non-POSIX shells i.e. Fish. ## Type of Change - [ ] New module - [ ] New template - [x] Bug fix - [x] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information **Path:** `registry/coder/modules/dotfiles` **New version:** `v1.4.1` **Breaking change:** [ ] Yes [ ] No ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun fmt`) - [x] Changes tested locally ``` bun test v1.3.8 (b64edcb4) registry/coder/modules/dotfiles/main.test.ts: ✓ dotfiles > required variables [190.40ms] ✓ dotfiles > missing variable: agent_id [43.12ms] ✓ dotfiles > default output [150.15ms] ✓ dotfiles > set a default dotfiles_uri [159.14ms] ✓ dotfiles > command uses bash for fish shell compatibility [164.08ms] ✓ dotfiles > set custom order for coder_parameter [166.50ms] 6 pass 0 fail 7 expect() calls Ran 6 tests across 1 file. [1184.00ms] ``` I tested this with a new workspace on Coder v2.27.3 with fish, zsh, and bash. --------- Co-authored-by: DevCats Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> --- registry/coder/modules/dotfiles/README.md | 12 ++++++------ registry/coder/modules/dotfiles/main.test.ts | 15 +++++++++++++++ registry/coder/modules/dotfiles/main.tf | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/registry/coder/modules/dotfiles/README.md b/registry/coder/modules/dotfiles/README.md index aae52284..2cab271b 100644 --- a/registry/coder/modules/dotfiles/README.md +++ b/registry/coder/modules/dotfiles/README.md @@ -18,7 +18,7 @@ Under the hood, this module uses the [coder dotfiles](https://coder.com/docs/v2/ module "dotfiles" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/dotfiles/coder" - version = "1.4.0" + version = "1.4.1" agent_id = coder_agent.example.id } ``` @@ -31,7 +31,7 @@ module "dotfiles" { module "dotfiles" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/dotfiles/coder" - version = "1.4.0" + version = "1.4.1" agent_id = coder_agent.example.id } ``` @@ -42,7 +42,7 @@ module "dotfiles" { module "dotfiles" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/dotfiles/coder" - version = "1.4.0" + version = "1.4.1" agent_id = coder_agent.example.id user = "root" } @@ -54,14 +54,14 @@ module "dotfiles" { module "dotfiles" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/dotfiles/coder" - version = "1.4.0" + version = "1.4.1" agent_id = coder_agent.example.id } module "dotfiles-root" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/dotfiles/coder" - version = "1.4.0" + version = "1.4.1" agent_id = coder_agent.example.id user = "root" dotfiles_uri = module.dotfiles.dotfiles_uri @@ -90,7 +90,7 @@ You can set a default dotfiles repository for all users by setting the `default_ module "dotfiles" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/dotfiles/coder" - version = "1.4.0" + version = "1.4.1" agent_id = coder_agent.example.id default_dotfiles_uri = "https://github.com/coder/dotfiles" } diff --git a/registry/coder/modules/dotfiles/main.test.ts b/registry/coder/modules/dotfiles/main.test.ts index a9a8bf93..67e0f4a9 100644 --- a/registry/coder/modules/dotfiles/main.test.ts +++ b/registry/coder/modules/dotfiles/main.test.ts @@ -56,6 +56,21 @@ describe("dotfiles", async () => { } }); + it("command uses bash for fish shell compatibility", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + manual_update: "true", + dotfiles_uri: "https://github.com/test/dotfiles", + }); + + const app = state.resources.find( + (r) => r.type === "coder_app" && r.name === "dotfiles", + ); + + expect(app).toBeDefined(); + expect(app?.instances[0]?.attributes?.command).toContain("/bin/bash -c"); + }); + it("set custom order for coder_parameter", async () => { const order = 99; const state = await runTerraformApply(import.meta.dir, { diff --git a/registry/coder/modules/dotfiles/main.tf b/registry/coder/modules/dotfiles/main.tf index ca1709d0..226a9ab5 100644 --- a/registry/coder/modules/dotfiles/main.tf +++ b/registry/coder/modules/dotfiles/main.tf @@ -164,12 +164,12 @@ resource "coder_app" "dotfiles" { icon = "/icon/dotfiles.svg" order = var.order group = var.group - command = templatefile("${path.module}/run.sh", { + command = "/bin/bash -c \"$(echo ${base64encode(templatefile("${path.module}/run.sh", { DOTFILES_URI : local.dotfiles_uri, DOTFILES_USER : local.user, DOTFILES_BRANCH : local.dotfiles_branch, POST_CLONE_SCRIPT : local.encoded_post_clone_script - }) + }))} | base64 -d)\"" } output "dotfiles_uri" {