setup-node: Error: Unable to locate executable file: yarn. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
I have
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
Maybe my expectation is incorrect, but I would expect this package to setup node and yarn on the machine.
Description:
crashes with Error: Unable to locate executable file: yarn. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
Action version: 3
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Tools version: node 16
Repro steps:
Expected behavior: yarn get’s installed as part of this step
Actual behavior: crashes with
Run actions/setup-node@v3
Found in cache @ /Users/runner/actions-runner/_work/_tool/node/16.15.0/arm64
Error: Unable to locate executable file: yarn. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (2 by maintainers)
Also running into this on self-hosted. Used to work fine on GitHub hosted runners.
A bit odd indeed that yarn is a precondition for setting up node here.
I just ran into this problem, and I’m curious why the setup-node action doesn’t you know, setup node? Doesn’t pre-installing tools on the self-hosted runner defeat the purpose?
of course I don’t. I do not know why I was expecting this action to set it up. Sorry
Hello @capaj. Thank you for your report. Do you have yarn preinstalled on your self-hosted runner ?
@dmitry-shibanov I disagree,
yarn/pnpmare not some random extra tools, they are pretty core to the NodeJS ecosystem and used pretty extensively. Thissetup-nodeaction acknowledges this by giving support for caching dependencies installed with those tools. IMHO, it doesn’t make sense that I need to somehow, installyarnafter usingsetup-node, loosing the ability to use the build in caching support and hacking it like @neseleznev showed.IMO the action should just call
corepackas part of the install. If the repo haspackageManagerset, everything will just work.Hello @milesj. The hosted runners have preinstalled versions of software such as yarn node and etc. The main purpose of setup-node is to set up Nodejs on the machine that is why we’re not going to install some extra tools. Besides, that if the action had been installing tools by default it would require clean up machine from it. It looks like something out of scope of action.
I don’t think you’re dumb at all! 😅
I’d suggest using
corepackin a separate step while it’s not included as part of this action (it probably should be).Corepack is included as opt-in since
Node.js 14.19 / 16.9The solution is simple, portable and reliable. It’ll automatically use the correct version for both Node and Yarn across all platforms.
package.json
Note: Volta compliments well but is not required. If you use it, the package manager version should be in sync with the
packageManagervalue.Workflow
Note: using both
--frozen-lockfileand--immutablewill make sure it works for both older and newer version of Yarn, making it more portable across repos with different yarn versions.Why not
npm install --global yarn?Re: @markanthonyuy and @onxb
Actually yarn recommends against this approach, in favour of Corepack. Source: https://yarnpkg.com/corepack
I hit this today when using
act.@neseleznev totally agree with you, to me it sounds like
yarnandpnpmare tools that should be controlled bysetup-node, specially if this action supports cache for those, otherwise, it’s contradictory.Agree with @milesj here. Especially considering that
corepackmakes installing yarn so easy, seems like setup-node should take care of this implicitly whenyarnis set as cache type, at least for newer node versions =)tldr: add step to install
yarnupon trying last response, I am getting following error 😃 corepack: command not found
thinks you
That’s not dumb at all. It’s quite opposite — I have to preinstall
yarnglobally (Node.jsnpmpackage) to the runner before installing Node.js 🤯I feel frustrated. For those who’s with me, try the approach to cache the whole
node_modulesas described in https://oozou.com/blog/ci-cd-tips-improve-your-ci-cd-with-cache-github-version-209Thus, my final action looks like
I’ve seen an action to run yarn without installing it on the runner
e.g.
https://github.com/marketplace/actions/github-action-for-yarn