-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description:
When sam build
tries to build a runtime: provided
Function
, if the build system uses relative paths then it will fail when copied to the temporary directory sam build
uses.
Steps to reproduce the issue:
Given a repository containing multiple Haskell libraries and services, structured roughly as follows:
/
├── lib
│ ├── lib1
│ │ └── stack.yaml
│ └── lib2
│ └── stack.yaml
└── service
├── service1
│ ├── Makefile
│ ├── samconfig.toml
│ ├── stack.yaml
│ └── template.yaml
└── service2
├── Makefile
├── samconfig.toml
├── stack.yaml
└── template.yaml
Each service under /service
is a separate CloudFormation stack, so I want to run sam build
in e.g. /service/service1
. The build system for the service (currently Stack, but not relevant) refers to its dependent libraries using relative paths, saying things like "use ../../lib/library1
".
Observed result:
When sam build
is run inside service/service1
(say), sam
copies the service1
subdirectory to a temporary location and invokes make
. make
then invokes stack
, which fails because the dependent libraries are not present at SOME_TEMP_DIR/../../lib/library1
etc.
Expected result:
I build my code successfully.
Remarks:
As a workaround, I have been able to find my way home with this snippet, but it feels dirty:
REAL_SRC := $(shell echo "$(ARTIFACTS_DIR)" | sed 's@/.aws-sam.*@@')
I am not sure what the best fix looks like. sam
's behaviour is by design, so perhaps the answer is to expose (via environment variable or similar) the repository root location and/or the original location of the source code?