MacOs Error: Error acquiring the state lock

When I run terraform plan on my Mac I get the following error:

imac:test2 dave$ terraform plan
╷
│ Error: Error acquiring the state lock
│ 
│ Error message: 2 errors occurred:
│ 	* operation not supported
│ 	* open .terraform.tfstate.lock.info: no such file or directory
│ 
│ 
│ 
│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended.
╵

Terraform version is:

imac:test2 dave$ terraform --version
Terraform v1.1.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.75.0

Any ideas what may be going wrong?

Thanks

Dave

1 Like

My guess from the lack of context in the error is that is being returned by the system when attempting to create or lock a file. Do you have write permissions in your working directory directory, and are you on a filesystem that supports POSIX locks?

Thanks for that. It does apppear to be a problem. I mounted the same device via nfs rather than smb but now I get the following:

Acquiring state lock. This may take a few moments...
╷
│ Error: Error acquiring the state lock
│ 
│ Error message: 2 errors occurred:
│ 	* no locks available
│ 	* open .terraform.tfstate.lock.info: no such file or directory
│ 
│ 
│ 
│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended.
╵

However, if I use -lock=false then everything is OK.

Thanks

Hello Dave,

I am getting the same error here. Any chance you ended up finding a workaround to this?

Thanks,

The issue seems to have been around having rpc.statd running on the remote server hosting the filesystem I was writing to. Once I got that running the issue went away.

I’m having the same issue - not running rpc.statd on a remote server though… Any ideas what could be causing this? I’m running on a Mac M1 if that makes any difference.

@mistwire, since the previous question was quite specific to problems due to running Terraform on a network filesystem, if your scenario does not involve a network filesystem, I recommend starting a new separate topic.