Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(pipeline): primaryOutputDirectory doesn't work

See original GitHub issue

What is the problem?

I coded just as mentioned about primaryOutputDirectory, but it fails to work. This is my code snippet.

    // The basic pipeline declaration. This sets the initial structure
    // of our pipeline
    const cdk_infra_path = "packages/cdk-infra";
    const cdk_infra_path_back = "../..";
    const cdk_out_path = "cdk.out";
    const steps = new pipelines.ShellStep("Synth", {
      input: pipelines.CodePipelineSource.codeCommit(repo, "master"),
      commands: [
        "cd " + cdk_infra_path,
        "npx lerna bootstrap --ci",
        "npx lerna run build",
        "npx cdk synth",
        "cd " + cdk_infra_path_back,
        "ln -s " + cdk_infra_path + "/" + cdk_out_path + " " + cdk_out_path,
      primaryOutputDirectory: cdk_infra_path + "/" + cdk_out_path,

    const pipeline = new pipelines.CodePipeline(this, "Pipeline", {
      pipelineName: SrvConfig.PIPELINE_NAME,
      synth: steps,

However, it fails me at the end with this CodeBuild log output.

< snip >
        BuildSpec: |-
            "version": "0.2",
            "phases": {
              "build": {
                "commands": [
                  "cd packages/cdk-infra",
                  "npx lerna bootstrap --ci",
                  "npx lerna run build",
                  "npx cdk synth",
                  "cd ../..",
                  "ln -s packages/cdk-infra/cdk.out cdk.out"
            "artifacts": {
              "base-directory": "packages/cdk-infra/cdk.out",  <=====
              "files": "**/*"
        Type: CODEPIPELINE
< snip >
[Container] 2022/01/06 18:37:12 Phase complete: BUILD State: SUCCEEDED
[Container] 2022/01/06 18:37:12 Phase context status code:  Message: 
[Container] 2022/01/06 18:37:12 Entering phase POST_BUILD
[Container] 2022/01/06 18:37:12 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2022/01/06 18:37:12 Phase context status code:  Message: 
[Container] 2022/01/06 18:37:12 Expanding base directory path: cdk.out  <=====
[Container] 2022/01/06 18:37:12 Assembling file list
[Container] 2022/01/06 18:37:12 Expanding cdk.out
[Container] 2022/01/06 18:37:12 Skipping invalid file path cdk.out
[Container] 2022/01/06 18:37:12 Phase complete: UPLOAD_ARTIFACTS State: FAILED
[Container] 2022/01/06 18:37:12 Phase context status code: CLIENT_ERROR Message: no matching base directory path found for cdk.out

The whole log: log-events-viewer-result (1).csv

My two cents on this. Maybe this code ( is reverting the path to cdk.out?

Please help. I need my CDK v2 + CodePipeline working for my customer.

Reproduction Steps

What did you expect to happen?

CDK v2 + CodePipeline + primaryOutputDirectory working in my CDK infra’s subdirectory of packages/cdk-infra.

What actually happened?

Failed at CodeBuild with the log mentioned above.

CDK CLI Version

2.4.0 (build 993f14d)

Framework Version


Node.js Version






Language Version

Version 4.1.3

Other information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

makemefeelgr8commented, Jan 10, 2022

I can confirm it doesn’t work on 2.5.0. I had to run cdk bootstrap to fix the issue. Though it said there were no changes, it actually helped.

byongwucommented, Jan 11, 2022

Thank you, @makemefeelgr8 and @rix0rrr for your time. Case resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

primary output directory `root/cdk.out` generates errors since ...
What is the problem? We observe in the default cdk pipeline: Failed to load notices from cache: Error: ENOENT: no such file or...
Read more >
Troubleshooting Cell Ranger -Software - Support
At the start of any cellranger pipeline, the software looks for its intended output directory. If such a directory exists, this directory/run is...
Read more >
aws-cdk/pipelines module - AWS Documentation -
This module contains two sets of APIs: an original and a modern version of CDK Pipelines. The modern API has been updated to...
Read more >
When I add this BucketDeployment to my CDK CodePipeline ...
TL;DR With two changes, the pipeline successfully deploys the React app: (1) Source.asset needs the full path to the build directory and (2) ......
Read more >
Troubleshooting ML pipelines - Azure Machine Learning
output_dir, exist_ok=True) to create the output directory. See the tutorial for a scoring script example that shows this design pattern.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found