Fix support for Yarn 2 (berry)
- Checks the version of Yarn installed globally using
YARN_IGNORE_PATH=1. The environment variableYARN_VERSIONsets the version of Yarn to install globally. - Sets
YARN_GLOBAL_FOLDERenvironment variable to the cache directory. Thecache-folderflag is deprecated in Yarn 2. The user can opt-in to use the global cache by settingYARN_ENABLE_GLOBAL_CACHEin Netlify settings. (See https://github.com/netlify/build-image/pull/465#discussion_r465539682)
Closes #319.
Suggestion for Docs: https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables
- * `YARN_VERSION`: Sets the [Yarn version].
+ * `YARN_VERSION`: Sets the [Yarn version] to install globally.
+ * `YARN_ENABLE_GLOBAL_CACHE`: Use the [global cache](https://yarnpkg.com/configuration/yarnrc#enableGlobalCache) for Yarn 2.
https://docs.netlify.com/configure-builds/manage-dependencies/#yarn
- * `YARN_VERSION`: defaults to the version preinstalled with your initial [build image]. Accepts any released version number.
+ * `YARN_VERSION`: defaults to the version preinstalled with your initial [build image]. Accepts any released version number. The specified version is installed globally.
+ * `YARN_ENABLE_GLOBAL_CACHE`: whether to use the [global cache](https://yarnpkg.com/configuration/yarnrc#enableGlobalCache) for Yarn 2. If you use zero-installs, do not set this variable.
CC @arcanis Could you check whether this is the right way to use Yarn 2 in CI?
Would love for this to be merged in so that I move a site over to netlify. 🙏
The line below export PATH=$(yarn bin):$PATH also needs to be updated; yarn bin on Yarn 2+ no longer returns a node_modules/.bin directory (which doesn't exist with PnP) but instead just lists all available binaries.
Closing this PR as the it's against xenial branch and the Xenial image is going to be deprecated: https://answers.netlify.com/t/please-read-end-of-support-for-xenial-build-image-everything-you-need-to-know/68239
Feel free to reopen against focal branch.