tfmigrate icon indicating copy to clipboard operation
tfmigrate copied to clipboard

Tool not working on windows

Open Olgoetz opened this issue 3 years ago • 5 comments

I have built tfmigrate from source for windows.

However, I receive:

failed to run command (exited 1): terraform state mv -state=C:\Users\i016249\AppData\Local\Temp\tmp3995434150 -state-out=C:\Users\i016249\AppData\Local\Temp\tmp3354553505 -backup=/dev/null module.network.data.aws_availability_zones.available module.network.data.aws_availability_zones.available
stdout:
Move "module.network.data.aws_availability_zones.available" to "module.network.data.aws_availability_zones.available"

stderr:
Error saving the state: failed to create local state backup file: open /dev/null: The system cannot find the path specified.

The state was not saved. No items were removed from the persisted
state. No backup was created since no modification occurred. Please
resolve the issue above and try again.

How can I make it work for windows as it does not have /dev/null ?

Olgoetz avatar May 27 '22 15:05 Olgoetz

Hi @Olgoetz, Thank you for reporting this!

The current implementation specifies /dev/null directly, but the os.DevNull constant points to the NUL device on Windows. I don't have a Windows device for testing; would it be possible for you to try it? If you are not familiar to Go, please let me know. https://pkg.go.dev/os#pkg-constants

minamijoyo avatar May 30 '22 01:05 minamijoyo

I will try it

Olgoetz avatar Jun 03 '22 10:06 Olgoetz

I just cloned the repo and encountering now this:

2022/06/03 13:43:24 [INFO] [executor@C:\Users\i016249\DEVELOPMENT\tfmigrate] create an override file
2022/06/03 13:43:24 [INFO] [migrator@C:\Users\i016249\DEVELOPMENT\tfmigrate] creating local workspace folder in: C:\Users\i016249\DEVELOPMENT\tfmigrate\terraform.tfstate.d\default
2022/06/03 13:43:24 [INFO] [executor@C:\Users\i016249\DEVELOPMENT\tfmigrate] switch backend to local
2022/06/03 13:43:24 [DEBUG] [executor@C:\Users\i016249\DEVELOPMENT\tfmigrate]$ terraform init -input=false -no-color -reconfigure
2022/06/03 13:43:26 [DEBUG] [executor@C:\Users\i016249\DEVELOPMENT\tfmigrate] failed to run command: (*exec.ExitError)(0x12cba0c0)(exit status 1)
failed to switch backend to local: failed to run command (exited 1): terraform init -input=false -no-color -reconfigure
stdout:

Initializing the backend...

stderr:

Error: Error asking for state migration action: input is disabled

Olgoetz avatar Jun 03 '22 12:06 Olgoetz

It's maybe related to https://github.com/minamijoyo/tfmigrate/issues/45. The tfmigrate doesn't work with the local backend. It requires a remote state backend.

minamijoyo avatar Jun 03 '22 13:06 minamijoyo

FYI, I've got 0.3.3 working great on my Windows 10 machine.

Tzrlk avatar Jun 14 '22 10:06 Tzrlk