From a86c957871b9999efd5b1f772a0471c7d1924cf3 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 8 Jun 2022 11:22:18 -0700 Subject: [PATCH] feat: set /Users/spike for coder agent in gcp-linux template (#2147) 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 a53a29127b..d97bdae312 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 }