Skip to content

sam build includes absolute paths in Golang binaries #3258

@suroh1994

Description

@suroh1994

Description:

When you run sam build and sam package in two instances of the same projects with different absolute paths and upload to the same S3 bucket, the compiled binaries will be uploaded both times, even though the binaries are identical.
According to #2110 this has been fixed, but I can still reproduce the issue on Windows.

Steps to reproduce:

  1. Clone this repository into a directory on your local Windows machine.
  2. cd into the directory.
  3. Run sam build.
  4. Run sam package --s3-bucket YOUR_BUCKETNAME
  5. Clone the same repository into a second directory on your local windows machine.
  6. Copy the second directory into a third directory using xcopy seconddirectory thirddirectory /s /e.
  7. cd into the second directory.
  8. Run sam build.
  9. Run sam package --s3-bucket YOUR_BUCKETNAME
  10. cd into the third directory.
  11. Run sam build.
  12. Run sam package --s3-bucket YOUR_BUCKETNAME

Observed result:

The calculated hashes change, when the parent directory changes. This results in the compiled binaries being re-uploaded for every directory, although no files have been modified.

Expected result:

Hashes should not depend on the parent directory. Compiled binaries should only be uploaded, when they have been modified.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows 10 Pro Version 20H2 (Build 19042.1165)
  2. sam --version: 1.31.0
  3. AWS region: eu-central-1

Further notes:

I can imagine this is also the cause for the issue #2872, where running sam package in an ephemeral container results in the files being uploaded every time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions