-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in post-job step of CacheV2 task when caching yarn packages #12892
Comments
Same issue here, but this time with npmStarting: Cache npm
|
Same issue here on a hosted linux agent
|
Same issue here with yarn - it is in some autogenerated task after my WAR deploy is done - the task is called "Post-job: Cache": tar: /blah/blahgent/_work/1/s//node_modules, !/node_modules/**/node_modules: Cannot open: No such file or directory Any clue how to solve? |
Came in here to +1 to this, below is my config:
|
For me it works, but I have set the directory directly because I found no suitable pipeline variable:
I'm using a hosted agent (ubuntu-18.04); maybe this works for you as well. |
@jfheins thanks for the hint. Current configuration works for me in cloud-hosting: pool:
vmImage: 'ubuntu-latest'
variables:
- name: YARN_CONFIG_CACHE
value: /home/vsts/.cache/yarn/v6
...
- task: Cache@2
displayName: Cache node modules
inputs:
key: 'yarn | "$(Agent.OS)" | yarn.lock'
restoreKeys: |
yarn | "$(Agent.OS)"
path: $(YARN_CONFIG_CACHE) |
This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days |
Bumping because this is still happening and I don't think it should be closed |
I was running into this exact issue and fixed it by adding YARN_CACHE_FOLDER to the pipeline variables. I had the Cache task as part of a task group and in the pipeline that uses the task group, there is a required field that asks for the value of Once I also defined |
Bump - this actually just started happening on a build that hasn't changed since December. |
Same here for Maven: variables:
IS_MASTER_OR_DEVELOP: $[in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/develop')]
MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Cache@2
displayName: "Cache Maven local repo"
inputs:
key: 'maven | "$(Agent.OS)" | **/pom.xml'
restoreKeys: |
maven | "$(Agent.OS)"
maven
path: $(MAVEN_CACHE_FOLDER)
- task: Maven@3
displayName: "Publish artifacts"
condition: eq(variables.IS_MASTER_OR_DEVELOP, true)
inputs:
mavenPomFile: './pom.xml'
mavenOptions: '-Xmx3072m $(MAVEN_OPTS)'
mavenAuthenticateFeed: true
goals: 'deploy' |
Same as @loxy |
I'm not sure why the pipeline I created started throwing the
|
@loxy Any Suggestion ? I'm also stuck here . |
@pradpant No, didn't found a solution |
bump! |
This was working in a single stage pipeline, once I added another stage that causes this to get called twice, I now get the error with the cache post-job
|
Same here. Seems the cache plugin is broken. Found another solution here: https://xebia.com/blog/caching-your-node-modules-in-azure-devops/ |
This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days |
/remove-stale |
I'm also running into this issue, also with two consecutive @cache2 tasks (one for $(Pipeline.Workspace)/.npm
|
I think caching will only work on a self hosted agent? |
No, this task is especially good for the Azure hosted agents. In a self hosted scenario, most of the caching works without this task. (For example: yarn has a machine wide global cache that persists in a self hosted agent) The tricky thing is to get the cache directory right. I'd recommend to include a step that logs out the cache directories for easier troubleshooting:
|
SolutionSo, the issue seems to be that # example for .npm
# replace this
variables:
CACHE_FOLDER: $(Pipeline.Workspace)/.npm
# with this
variables:
CACHE_FOLDER: /home/vsts/.npm
ResultHere's the result of the successful run after making the change |
I have the same error, but with pnpm. This is the yaml from the docs: variables:
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store
steps:
- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: $(pnpm_config_cache)
displayName: Cache pnpm
- script: |
corepack enable
corepack prepare pnpm@latest-8 --activate
pnpm config set store-dir $(pnpm_config_cache)
displayName: "Setup pnpm"
- script: |
pnpm install
pnpm run build
displayName: "pnpm install and build" |
@vixero-dev Can you share your the log from the task failure? A lot of these issues look like folks either aren't:
|
@johnterickson you are correct. The variable wasn't being set. After changing this part: - script: |
corepack enable
corepack prepare pnpm@latest-8 --activate
pnpm config set store-dir $(pnpm_config_cache)
displayName: "Setup pnpm" to this: - script: |
corepack enable
corepack prepare pnpm@latest-8 --activate
displayName: "setup pnpm"
- script: pnpm config set store-dir $(pnpm_config_cache)
displayName: "setup pnpm config" I stopped experiencing this issue. |
I had some similar issues that ended up being due to agents getting different versions of yarn.
along with configuring the |
Also experience this issue when following Microsoft's documentation. It is an issue with the paths. This blog posts is a great dive into how to fix this and the Cache task. |
Try adding an
To:
This is because when using |
Required Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Bug
Enter Task Name: CacheV2 (https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/CacheV2)
Environment
Server - Azure Pipelines
Agent - Hosted:
Issue Description
Using the CacheV2 task to cache Yarn packages, we're getting an error in the post-job step of the cache task.
The task is defined exactly as in the docs.
We're using the
vs2017-win2016
image.Error logs
The text was updated successfully, but these errors were encountered: