minamijoyo / tfmigrate

A Terraform / OpenTofu state migration tool for GitOps
MIT License
1.14k stars 57 forks source link

Error executing ftmigrate on MacOS 14.0 (ARM) #168

Open CommanderK5 opened 9 months ago

CommanderK5 commented 9 months ago

Hey Folks!

When attempting to use ftmigrate i get the following error:

2024/02/07 16:03:28 [DEBUG] [main] start: tfmigrate apply
2024/02/07 16:03:28 [DEBUG] [main] tfmigrate version: 0.3.20
2024/02/07 16:03:28 [DEBUG] [command] load configuration file: .tfmigrate.hcl
2024/02/07 16:03:28 [DEBUG] [command] config: &config.TfmigrateConfig{MigrationDir:".", IsBackendTerraformCloud:false, History:(*history.Config)(0x14000032bc0)}
2024/02/07 16:03:28 [DEBUG] [command] option: &tfmigrate.MigratorOption{ExecPath:"", PlanOut:"", IsBackendTerraformCloud:false, BackendConfig:[]string(nil)}
2024/02/07 16:03:28 [DEBUG] [history] load migration dir: .
2024/02/07 16:03:28 [DEBUG] [history] load history
2024/02/07 16:03:28 [DEBUG] [history] read storage &local.Storage{config:(*local.Config)(0x1400021f4d0)}
2024/02/07 16:03:28 [TRACE] [history] read history file: []byte{}
2024/02/07 16:03:28 [DEBUG] [history] new empty history
2024/02/07 16:03:28 [INFO] [runner] unapplied migration files: [platform.hcl]
2024/02/07 16:03:28 [INFO] [runner] load migration file: platform.hcl
2024/02/07 16:03:28 [INFO] [migrator] start multi state migrator plan phase for apply
2024/02/07 16:03:28 [DEBUG] [executor@./state/vpc.tfstate.json]$ terraform version
2024/02/07 16:03:28 [TRACE] [executor@./state/vpc.tfstate.json] cmd=(*tfexec.command)(0x14000125848)({
 osExecCmd: (*exec.Cmd)(0x140001462c0)(/opt/homebrew/bin/terraform version),
 stdout: (*bytes.Buffer)(0x140001766c0)(),
 stderr: (*bytes.Buffer)(0x140001766f0)()
})

2024/02/07 16:03:28 [DEBUG] [executor@./state/vpc.tfstate.json] failed to run command: (*fs.PathError)(0x14000176720)(fork/exec /opt/homebrew/bin/terraform: not a directory)
2024/02/07 16:03:28 [ERROR] [runner] failed to apply: platform.hcl
2024/02/07 16:03:28 [DEBUG] [runner] length of history records: beforeLen = 0, afterLen = 0
fork/exec /opt/homebrew/bin/terraform: not a directory

Terraform version: 1.6.6 Macos: 14.0 tfmigrate: 0.3.20

I've tried docker-compose sandbox and got the exact same error. Maybe I'm missing something here.

2024/02/07 15:00:22 [INFO] [runner] unapplied migration files: [platform.hcl]
2024/02/07 15:00:22 [INFO] [runner] load migration file: platform.hcl
2024/02/07 15:00:22 [INFO] [migrator] start multi state migrator plan phase for apply
2024/02/07 15:00:22 [ERROR] [runner] failed to apply: platform.hcl
fork/exec /usr/local/bin/terraform: not a directory

I've tried to set different values for TFMIGRATE_EXEC_PATH but no joy so far.

minamijoyo commented 9 months ago

I tried it on macOS 14.2 (arm) but could not reproduce the issue. It seems to be an environment-specific issue. From your logs, the terraform version command fails to execute. Is it possible to execute the terraform version command without tfmigrate?

Also, I cannot reproduce this in a sandbox environment, so it may be a configuration issue. Please share the minimum settings that can be reproduced in the sandbox environment so we can investigate further.