-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Yarn is not installed #182
Comments
Workaround is to install yarn yourself using npm (after running this action)
and later can uninstall it -
While this works, I find it rather hacky. It would be good for this action to not need to rely on github's instances to have yarn package installed. EDIT: |
GitHub Runners creates a file called .path in the same directory where you have config.sh. It contains the content of You have to add a directory with the yarn binary. In my case: /home/github/.yarn/bin` |
@pperzyna thanks! I spent 30mins guessing why it was not working even after updating the path. Seems |
Hey @GoldFlsh , why should we uninstall |
@konsalex Since self-hosted runners are shared and are not a clean instance per job execution, like a github hosted runner would be, the job should do its best to clean itself up after a run so that each future workflow run is running on what amounts to a fresh instance. If you install software during the run, such as yarn, redis, or terraform without uninstalling it, could potentially cause conflicts with other jobs running as the state of the instance moves further away from the original state. Say then you try to upgrade versions of something in your workflow but since the old version is still installed from a previous run it may use that and create a difficult to debug situation. As others have mentioned you can pre-install any software on a self-hosted runner so the workflow itself does not have to be responsible for installing anything, which would side-step this altogether. Up to you, of course, how you best want to manage that 😃 |
Note that if you use |
To +1 on Davide's comment, the lack of yarn install support is a significant obstacle to those of us on self-hosted runners. The only way to break the chicken-or-egg |
Hi everyone. I faced the same problem and this may sound really stupid, but I solved it this way: jobs:
node-ci:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Setup Nodejs and npm
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Setup yarn
run: npm install -g yarn
- name: Setup Nodejs with yarn caching
uses: actions/setup-node@v2
with:
node-version: "14"
cache: yarn
- name: Install dependencies
run: yarn NOTE: This way, if you run the yarn uninstall in the step, the Post process will not be able to find yarn and the job will fail. Actions log shows that the cache was successful, but I am not sure if it is really cached in this case. Cache Size: ~118 MB (124177777 B)
Cache saved successfully
Cache saved with the key: foo-bar-baz When I connected to the runner instance that ran the job and ran the yarn command, I got not found, so everything seems to be working. However, this is not an essential solution and I also hope that yarn will be installed with it. |
FYI: There isn't a chicken-and-egg problem, you don't need Node to install yarn:
|
I think the point of contention here is that we need to return the runner back clean. It's easy enough to install the binaries, but given the hassle of making sure they're purged every time, I'd prefer to see them included under Node's control |
Thanks @pperzyna Let me share my approach, maybe it will useful. Find out where is the yarnFirst on your server run: then you got the yarn location, like this
copy the path (not including the yarn)
Edit pathrun
you got something like
separated with then paste the so the
Don't add the enter or something. Just give the Restart runnerYou need restart it. so it will load the new path Mostly you are running with
Run it again
|
While Node 17 isn't LTS, moving forward with Node 18 LTS (or >=16.10 LTS) it would be great if Corepack is part of the node install itself and contains both yarn and pnpm but is currently opt-in. It's also the recommended way to use/install yarn 2+. You can enable it manually in a single step which fixed the issue for me: jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '17'
cache: 'yarn'
- run: corepack enable
- run: yarn install
- run: yarn lint |
This doesn't solve this issue. It's only working for you because you're using |
I have the error What is the best way to fix it ? # Install node.js and yarn
- uses: Clovis-team/action-setup-node@v3
with:
node-version: '14'
# Get yarn cache directory path in order to cache it
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=version::$(yarn -v)"
shell: bash Log in github:
|
Hi, a lot of great answers here! ...
- name: Install yarn
run: |-
curl -fsSL --create-dirs -o $HOME/bin/yarn \
https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn-1.22.19.js
chmod +x $HOME/bin/yarn
echo "$HOME/bin" >> $GITHUB_PATH
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
... Curl needs the |
* docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
This is useful e.g. for act [1] if using the medium-sized image. Taken from user @francis-switcho’s comment on actions/setup-node. [2] [1]: https://github.com/nektos/act#default-runners-are-intentionally-incomplete [2]: actions/setup-node#182 (comment)
Let me get this straight, the solution is for the consumers to:
tldr. |
Corepack & Yarn is a bad joke. Prior to this yaml on node 20 use ...
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
- run: |
corepack enable &&
corepack install # use the in-repo yarn version
- name: Setup Yarn in Node
uses: actions/setup-node@v4
with:
cache: "yarn" # uses the system node, which was updated prior.
... |
Running into this issue in July 2024... Current workaround: vitest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
# FIXME: Because the setup-node action is dumb, we have to manually
# install the dependencies ourselves. See: https://github.com/actions/setup-node/issues/182
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn test:unit:ci |
Another workaround is to replace all calls to |
After upgrading to Node 22, Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/opt/actions-runner/_work/_tool/node/22.11.0/x64/bin/pnpm'
at async Object.symlink (node:internal/fs/promises:1001:10)
at async EnableCommand.generatePosixLink (/opt/actions-runner/_work/_tool/node/22.[11](https://github.com/creditornot/converse-services/actions/runs/11659651461/job/32460569908#step:8:12).0/x64/lib/node_modules/corepack/dist/lib/corepack.cjs:22608:5)
at async Promise.all (index 0)
at async EnableCommand.execute (/opt/actions-runner/_work/_tool/node/22.11.0/x64/lib/node_modules/corepack/dist/lib/corepack.cjs:22595:5)
at async EnableCommand.validateAndExecute (/opt/actions-runner/_work/_tool/node/22.11.0/x64/lib/node_modules/corepack/dist/lib/corepack.cjs:19835:22)
at async _Cli.run (/opt/actions-runner/_work/_tool/node/22.11.0/x64/lib/node_modules/corepack/dist/lib/corepack.cjs:20772:18)
at async Object.runMain (/opt/actions-runner/_work/_tool/node/22.11.0/x64/lib/node_modules/corepack/dist/lib/corepack.cjs:23091:19) Worked around using this (requires - corepack enable
+ npm install -g $(jq -r '.packageManager' package.json) Without jq: - corepack enable
+ npm install -g $(sed -nE 's/.*"packageManager": "([^"]+)".*/\1/p' package.json) |
## Proposed change In `node-setup` GitHub action, passing `cache: yarn` doesn't work well with corepack (see issues below). The goal is to do the cache manually for yarn and to let `node-setup` do it for `npm`. ## Related issues <!-- Please make sure to follow the [contribution guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md) --> actions/setup-node#531 actions/setup-node#182 <!-- * 🐛 Fix #issue --> <!-- * 🐛 Fix resolves #issue --> <!-- * 🚀 Feature #issue --> <!-- * 🚀 Feature resolves #issue --> <!-- * Pull Request #issue -->
We are using a self-hosted runner and using this action to setup-node and install yarn.
I know on github-hosted runners, yarn is already pre-installed but it would be good if yarn was installed by this action for those of us using self-hosted.
Running setup-node with the following workflow and it works
Note that node and npm are installed.
A later step in the workflow then attempts to run yarn:
This of course works on github hosted runners just fine, but since I just migrated to an EC2 instance that doesn't have yarn installed, I am now having issues.
The text was updated successfully, but these errors were encountered: