-
Notifications
You must be signed in to change notification settings - Fork 196
Yarn 3 workspaces are not cached at all #615
Comments
Thanks for raising this @marcofugaro. This is definitely related with #612 and #319 and our usage of the |
This issue is five months old today and there is still no solution for Yarn 3 in the public. I tried finding a workaround today but gave up: netlify/build#1535 (comment) HALP! 🙏 UPD: Workaround: netlify/build#1535 (comment) |
Hi, manage to create a workaround for yarn3 using a custom plugin, till #612 First in [build.environment]
NODE_VERSION = "16"
NPM_FLAGS = "--version"
[[plugins]]
package = "/.netlify/netlify-plugin-yarn" then create
manifest.yml is just name: netlify-plugin-yarn
inputs: [] and index.js is responsible for moving cache folder, setting module.exports = {
onPreBuild: async ({ utils: { build, run } }) => {
const cacheDir = '.yarn_cache'
process.env['YARN_CACHE_FOLDER'] = `${process.env.HOME}/${cacheDir}`
process.env['NETLIFY_CACHE_DIR'] = `${process.env.NETLIFY_BUILD_BASE}/cache`
try {
await run.command(`mv ${process.env.NETLIFY_CACHE_DIR}/${cacheDir} ${process.env.YARN_CACHE_FOLDER}`)
} catch (error) {
console.log('No yarn cache found')
}
try {
await run.command('corepack enable')
} catch (error) {
return build.failBuild(error)
}
},
} package.json {
"private": true,
"engines": {
"node": "16.x",
"yarn": "3.2.1"
},
"packageManager": "[email protected]"
} Edited --- Extracted this code into package, https://github.com/piecyk/yarn-berry-netlify-plugin |
Related: #612 #432 #319
We are using yarn workspaces with yarn's latest version (
3.0.1
) and yarn is not cached at all, it takes1m 54s
in best cases and3m 17s
in worst cases, including the cache restore phase.On the contrary, on GitHub actions with the yarn cache action, the Fetch phase is completely skipped, and it just runs the linking phase. It takes ~20 seconds.
I pasted the logs at the end of the issue, the relevant part are these:
And there is this warning from yarn, it may be relevant:
Full Netlify build logs (excluding build phase)
The text was updated successfully, but these errors were encountered: