Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic/crash when running 'terraform init' #21653

Closed
brikis98 opened this issue Jun 7, 2019 · 6 comments
Closed

Panic/crash when running 'terraform init' #21653

brikis98 opened this issue Jun 7, 2019 · 6 comments

Comments

@brikis98
Copy link
Contributor

brikis98 commented Jun 7, 2019

Terraform Version

Terraform v0.12.0

Terraform Configuration Files

In a folder called hello-world, I have a main.tf with the contents:

data "template_file" "test" {
  template = "${module.hello.hello}, ${var.name}"
}

variable "name" {
  description = "Specify a name"
}

output "test" {
  value = "${data.template_file.test.rendered}"
}

module "hello" {
  source = "./hello"
}

module "remote" {
  source = "github.com/gruntwork-io/terragrunt.git//test/fixture-download/hello-world?ref=v0.9.9"
  name = "${var.name}"
}

The module code being downloaded in source is this: https://github.com/gruntwork-io/terragrunt/tree/v0.9.9/test/fixture-download/hello-world

Expected Behavior

I can run terraform init -from-module=../hello-world . without errors.

Actual Behavior

Terraform panics and crashes:

Copying configuration from "file:///Users/brikis98/src/github.com/gruntwork-io/terragrunt/test/fixture-download/hello-world"...
Downloading github.com/gruntwork-io/terragrunt.git?ref=v0.9.9 for remote...
panic: Rel: can't make /Users/brikis98/src/github.com/gruntwork-io/terragrunt/test/fixture-download/hello-world/hello relative to 

goroutine 1 [running]:
github.com/hashicorp/terraform/internal/initwd.DirFromModule(0x7ffeefbffa3c, 0x49, 0xc000042280, 0x12, 0x7ffeefbff97c, 0x5f, 0xc000294140, 0x2bcf480, 0xc00000c100, 0x18, ...)
	/opt/gopath/src/github.com/hashicorp/terraform/internal/initwd/from_module.go:269 +0x364c
github.com/hashicorp/terraform/command.(*Meta).initDirFromModule(0xc0000af1e0, 0x7ffeefbffa3c, 0x49, 0x7ffeefbff97c, 0x5f, 0x2bcf480, 0xc00000c100, 0x6, 0x0, 0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/command/meta_config.go:252 +0x194
github.com/hashicorp/terraform/command.(*InitCommand).Run(0xc0000af1e0, 0xc00003a0a0, 0x5, 0x6, 0xc0003f00c0)
	/opt/gopath/src/github.com/hashicorp/terraform/command/init.go:148 +0x2992
github.com/mitchellh/cli.(*CLI).Run(0xc00044a500, 0xc00044a500, 0xc000531d90, 0x1)
	/opt/gopath/pkg/mod/github.com/mitchellh/cli@v1.0.0/cli.go:255 +0x1f1
main.wrappedMain(0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/main.go:223 +0xaff
main.realMain(0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/main.go:100 +0xb4
main.main()
	/opt/gopath/src/github.com/hashicorp/terraform/main.go:36 +0x3b



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Steps to Reproduce

terraform init -from-module=../hello-world
@ghost ghost added bug crash labels Jun 7, 2019
@brikis98
Copy link
Contributor Author

brikis98 commented Jun 7, 2019

Update: removing the following fixes the crash:

module "hello" {
  source = "./hello"
}

So something about calling init -from-module=foo on a module foo that itself contains a module with source set to a relative path causes a crash.

@brikis98
Copy link
Contributor Author

brikis98 commented Jun 7, 2019

For context, I'm hitting this as part of upgrading Terragrunt to work with Terraform 0.12. Terragrunt uses terraform init -from-module extensively, so if that's broken when downloading any module that references other modules, this will be a blocker. I asked in #18460 if it would be better for Terragrunt to use go-getter directly to work around another issue with init -from-module; perhaps now is the time to do that after all?

@josh-padnick
Copy link

josh-padnick commented Jun 7, 2019

Try with Terraform 0.12.1?

@brikis98
Copy link
Contributor Author

brikis98 commented Jun 7, 2019

Same crash with 0.12.1.

@pselle
Copy link
Contributor

pselle commented Aug 5, 2019

Hi @brikis98! When I try to replicate this, I get an error that is the same both with and without the . at the end of the command. Please let us know if you're still seeing this, and any further replication if so.

$ terraform init -from-module=../hello-world 
The working directory already contains files. The -from-module option requires
an empty directory into which a copy of the referenced module will be placed.

To initialize the configuration already in this working directory, omit the
-from-module option.

@ghost
Copy link

ghost commented Sep 5, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants