Skip to content

Dotfiles are lost in copy when using the same module multiple times #36884

Closed as duplicate of#30740
@lesteenman

Description

@lesteenman

Terraform Version

Terraform v1.11.4
on darwin_arm64

Terraform Configuration Files

Given a terraform module at bitbucket.org:some/internal-project:

module "module_copy_1" {
  source = "git::[email protected]:our-organization/parent-project?ref=2.8.0"

  # Properties
}

module "module_copy_2" {
  source = "git::[email protected]:our-organization/parent-project?ref=2.8.0"

  # Properties
}

Where parent-project has the following module:

module "internal_project_release_5_0_6" {
  source             = "git::[email protected]:our-organization/internal-project?ref=5.0.6"
  upload_prefix = "releases/5.0.6"
}

And our-organization/internal-project has:

resource "qbee_filemanager_file" "some_hidden_file" {
  path        = "${var.upload_prefix}/.update"
  sourcefile  = "${path.module}/files/shared/.update"
  file_sha256 = filesha256("${path.module}/files/shared/.update")
}

Debug Output

The relevant part of the debug output, where this module is copied:

2025-04-15T12:59:36.376+0200 [DEBUG] Module installer: begin module_copy_1.internal_project_release_5_0_6
2025-04-15T12:59:36.376+0200 [TRACE] ModuleInstaller: module_copy_1.internal_project_release_5_0_6 is not yet installed
2025-04-15T12:59:36.376+0200 [TRACE] ModuleInstaller: cleaning directory .terraform/modules/module_copy_1.internal_project_release_5_0_6 prior to install of module_copy_1.internal_project_release_5_0_6
2025-04-15T12:59:36.376+0200 [TRACE] ModuleInstaller: module_copy_1.internal_project_release_5_0_6 address "git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6" will be handled by go-getter
Downloading git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6 for module_copy_1.internal_project_release_5_0_6...
2025-04-15T12:59:36.376+0200 [TRACE] getmodules: fetching "git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6" to ".terraform/modules/module_copy_1.internal_project_release_5_0_6"
2025-04-15T12:59:42.533+0200 [TRACE] ModuleInstaller: module_copy_1.internal_project_release_5_0_6 "git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6" was downloaded to .terraform/modules/module_copy_1.internal_project_release_5_0_6
2025-04-15T12:59:42.538+0200 [DEBUG] Module installer: module_copy_1.internal_project_release_5_0_6 installed at .terraform/modules/module_copy_1.internal_project_release_5_0_6
- module_copy_1.internal_project_release_5_0_6 in .terraform/modules/module_copy_1.internal_project_release_5_0_6

...

2025-04-15T13:00:11.527+0200 [TRACE] ModuleInstaller: cleaning directory .terraform/modules/module_copy_2.internal_project_release_5_0_6 prior to install of module_copy_2.internal_project_release_5_0_6
2025-04-15T13:00:11.527+0200 [TRACE] ModuleInstaller: module_copy_2.internal_project_release_5_0_6 address "git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6" will be handled by go-getter
Downloading git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6 for module_copy_2.internal_project_release_5_0_6...
2025-04-15T13:00:11.527+0200 [TRACE] getmodules: copying previous install of "git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6" from .terraform/modules/module_copy_1.internal_project_release_5_0_6 to .terraform/modules/module_copy_2.internal_project_release_5_0_6
2025-04-15T13:00:11.660+0200 [TRACE] ModuleInstaller: module_copy_2.internal_project_release_5_0_6 "git::ssh://[email protected]/our-organization/internal-project?ref=5.0.6" was downloaded to .terraform/modules/module_copy_2.internal_project_release_5_0_6
2025-04-15T13:00:11.664+0200 [DEBUG] Module installer: module_copy_2.internal_project_release_5_0_6 installed at .terraform/modules/module_copy_2.internal_project_release_5_0_6
- module_copy_2.internal_project_release_5_0_6 in .terraform/modules/module_copy_2.internal_project_release_5_0_6

Expected Behavior

The hidden file in our internal-project/files/.update should be present for both module installations. I want to either force Terraform to not copy existing modules and download each time, or ideally, correctly use the cached directory and not ignore dot-files.

Actual Behavior

The file starting with a . is only present for the first module downloaded. The second module instead copies the installed module, as specified in

if prevDir, exists := g[packageAddr]; exists {
, ignoring the dot-files, as mentioned in
// Any "dot files" it encounters along the way are skipped, even on platforms
.

Steps to Reproduce

  1. terraform init
  2. terraform plan

The plan will fail since the dot-file does not exist, making the sha256 method crash.

Additional Context

No response

References

No response

Generative AI / LLM assisted development?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnewnew issue not yet triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions