Terraform "text file busy" error when applying a Coder workspace
Last updated: September 11, 2026
When creating or updating a Coder workspace, you may see Terraform fail with an error on the embedded provisioner(s) similar to this:
Failed to install provider
Error while installing coder/coder vX.Y.Z:
open /home/coder/.cache/coder/provisioner-N/tf/registry.terraform.io///X.Y.Z/linux_amd64/terraform-provider-_vX.Y.Z: text file busyon an External Provisioner it will look like:
/home/coder/.cache/coder/registry.terraform.io/coder/coder/X.Y.Z/linux_amd64/terraform-provider-coder_vX.Y.ZWhy this happens
This error comes from the Linux kernel and means a binary is being overwritten while it is still in use. In the context of Terraform and Coder:
Concurrent Terraform runs: Two or more Terraform processes attempt to install or use the same provider binary in the same cache path at the same time. Note that a single external provisioner daemon runs one build at a time, so this applies when several daemons share a cache directory, not within one pod.
Stale provider processes: A previous workspace build may not have exited cleanly, leaving the provider binary open. A new run that tries to overwrite that file will fail.
External file locks: In some environments, antivirus or filesystem security agents can hold temporary locks on provider binaries during install, leading to the same error.
Provider cache is purged on a timer: Coder deletes cached providers whose files have not been written in 30 days, checked on every build. Because the check uses mtime and a cache hit never updates mtime, a provider you use daily is still purged 30 days after it was installed - on every provisioner at roughly the same time. The next build must re-download and re-install it. This is a common reason builds suddenly slow down or fail to reach the registry across many workspaces with no config change, and it increases how often provider installs happen — installs being the only point at which
text file busyis possible.
Troubleshooting steps
When you encounter this error:
Check if multiple workspace operations are running concurrently on the same provisioner. If so, wait for one to finish before starting another. If you run one external provisioner per pod, builds there are already serialised, so look at stale processes and the 30-day purge instead.
Confirm your template includes a committed
.terraform.lock.hclfile. This reduces provider re-installs between runs. This requires you to runterraform *commands andcoder pushyour template to Coder.Confirm
/home/coder/.cacheis not a shared ReadWriteMany volume mounted across replicas, and that you are not running several daemons against one cache directory.On the provisioner host, list active provider processes:
ls -l /proc/*/exe 2>/dev/null | grep terraform-providerIf antivirus or endpoint protection is present, configure exclusions for the Coder provisioner cache directory.
On this error Coder fetches a goroutine dump from the hung terraform-provider-coder process and logs it at CRITICAL as "init: text file busy", with the dump in a provider_coder_stacktrace field. Attach that field or debug output to your ticket. If it is empty, the provider predates v1.0.4 or had already exited.
There is no automatic recovery. Coder detects the condition and fails the build, but does not kill the lingering process or restart the daemon — the provisioner stays broken for subsequent builds. By removing or killing the orphaned
terraform-provider-*process you unblock builds immediately. Restarting or recycling the pod is the cleaner fix and is what we recommend, since it also clears any other leaked state.
Mitigation and prevention
Run isolated caches: Give the (external) provisioner daemon a unique cache path (volume). In the case of external provisioner daemons, using CODER_CACHE_DIRECTORY/--cache-dir.
In all cases, do not point
CODER_CACHE_DIRECTORYat a volume shared between replicas (e.g. a ReadWriteMany PVC). Coder's configuration reference documents this directory as unsafe to share acrosscoderd/provisionerdreplicas.
Set explicit versions for providers in templates: Using explicit provider versions in your templates enables Terraform to better use the provider cache and prevent providers that have been updated from being fetched, potentially attempting to overwrite a binary in use.
Lock provisioners for all OS/Architectures in use: Use the
terraform provider lockand its--platformflag to create references in the.terraform.lock.hclfor each platform's provisioner binary. Use your judgement, for the need of lock/platform. This can prevent unexpected provider downloads on unspecified operating system and machine architectures. If the lock file is missing hashes for the platform a provisioner runs on, Coder logs a warning duringinit—.terraform.lock.hcl was modified during init— along with the exact command to regenerate it. If you see that warning in your provisioner logs, the lock file needs the additional platforms; if you don't, it doesn't.Lock files in templates: Always commit
.terraform.lock.hclby runningterraform initlocally before uploading the template to Coder so provider versions are pinned and stable. Reference: https://coder.com/docs/tutorials/best-practices/speed-up-templates#set-up-terraform-provider-cachingScale provisioners: If you need higher concurrency, deploy additional provisioner replicas so each has its own cache and lifecycle.
How you can help
If you find terraform-provider-coder binaries that are hanging and not exiting when they should, you can help us debug the issue by collecting a core dump of the hanging process, so that we can examine why it's hanging.
Collecting a core dump involves:
Getting a running shell inside the Coder server or external provisioner where the build is failing (e.g. via
kubectl exec)Verifying that an errant
terraform-provider-coderprocess is running there using the following command.ls -l /proc/*/exe 2>/dev/null | grep terraform-providerIncreasing its resource limits to allow it to dump a core file with prlimit
Triggering the core dump with
gdborgcore
If you can submit a core dump, attaching it to a GitHub issue, or for Coder customers a support ticket, would be much appreciated.
Another line of inquiry is looking into the filesystem_mirror option, so if you are using a ~/.terraformrc file, attaching a sanitized version of the file to the ticket would be helpful as well.
Version applicability
This behaviour is unchanged from the current main, 2.37, (and researched for 2.29-2.34): the cache environment injection, the external provisioner cache path, and the 30-day purge, so upgrading may not resolve this error. Tracking issue: https://github.com/coder/coder/issues/14726 (historical) and https://github.com/coder/coder/issues/21431 (open).
Summary
The text file busy error is not specific to Coder, but arises from how Terraform installs and executes providers. By ensuring isolation of cache directories, committing lock files, and avoiding concurrent writes to provider binaries, you can reduce, or prevent this error from disrupting workspace builds.