From 2d05690eaf5b3f2075765e7b29893908cb0bb3a8 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Tue, 7 Jun 2022 15:06:00 -0700 Subject: [PATCH] feat: set /Users/spike for coder agent in gcp-linux template Signed-off-by: Spike Curtis --- examples/templates/gcp-linux/main.tf | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index a53a29127bf2c..d97bdae3126a5 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -70,5 +70,21 @@ resource "google_compute_instance" "dev" { email = data.google_compute_default_service_account.default.email scopes = ["cloud-platform"] } - metadata_startup_script = coder_agent.dev.init_script + # The startup script runs as root with no $HOME environment set up, which can break workspace applications, so + # instead of directly running the agent init script, setup the home directory, write the init script, and then execute + # it. + metadata_startup_script = < /root/coder_agent.sh +${coder_agent.dev.init_script} +EOCODER +chmod +x /root/coder_agent.sh + +export HOME=/root +/root/coder_agent.sh + +EOMETA }