question-mark
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.

Trailing slash in outputs array prevents correct caching

See original GitHub issue

Current Behavior

I created a target with the following configuration:

{
...
  "targets": {
    "build": {
    "executor": "nx:run-commands",
    "outputs": ["some-folder-to-cache/"],
    "options": {
      "command": "mkdir -p some-folder-to-cache/ && echo foo > some-folder-to-cache/hello.txt"
    }
  }
...
}

When I run the target the first time (nx build myapp), it properly generates hello.txt in some-folder-to-cache. When I run it the second time, there is a cache-hit (Nx read the output from the cache instead of running the command for 1 out of 1 tasks.), but after that some-folder-to-cache is empty.

Expected Behavior

I would expect the previously cached file to still be present.

Reproduction

I found that I can fix the error, when I omit the trailing slash in the outputs array:

"outputs": ["some-folder-to-cache"],

instead of

"outputs": ["some-folder-to-cache/"],

Environment

 >  NX   Report complete - copy this into the issue template

   Node : 16.13.2
   OS   : darwin x64
   npm  : 8.1.2

   nx : 14.1.9
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.1.9
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.1.9
   @nrwl/js : Not Found
   @nrwl/linter : 14.1.9
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 14.0.5
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/workspace : 14.1.9
   typescript : 4.7.2
   ---------------------------------------
   Community plugins:

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
github-actions[bot]commented, Sep 14, 2022

This issue has been automatically marked as stale because it hasn’t had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

1reaction
niklasravnsborgcommented, Aug 29, 2022

There is already a fix for this available. The PR just needs to be reviewed. Is there anyone in the team that can take a look at it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the simplest way to remove a trailing slash from each ...
The accepted answer will trim ONE trailing slash. One way to trim multiple trailing slashes is like this:
Read more >
trailingslashit() | Function - WordPress Developer Resources
Returns preferred mime-type and extension based on provided file's extension and mime, or current file's extension and mime. Get the filesystem ...
Read more >
Configure Azure Static Web Apps - Microsoft Learn
Routes are defined as an array of routing rules. ... Conventionally, trailing slash URL refers to a directory on the web server, ...
Read more >
Configure Hosting behavior | Firebase Hosting - Google
Use a URL redirect to prevent broken links if you've moved a page or to shorten ... When unspecified, Hosting only uses trailing...
Read more >
To slash or not to slash | Google Search Central Blog
In the particular case of redirects to trailing slash URLs, our search ... and non-trailing-slash versions contain the same content and each returns...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found