Trailing slash in outputs array prevents correct caching
See original GitHub issueCurrent 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:
- Created a year ago
- Comments:10 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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! 🙏
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?