Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 944953 - app-misc/anki: require sys-apps/yarn, which conflict with net-libs/nodejs[corepack]
Summary: app-misc/anki: require sys-apps/yarn, which conflict with net-libs/nodejs[cor...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Patrick Lauer
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-25 16:35 UTC by OwenJia
Modified: 2024-12-29 18:55 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Tentative patch that multiple packages to provide /usr/bin/yarn (patch,456 bytes, patch)
2024-11-26 21:31 UTC, Lucio Sauer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description OwenJia 2024-11-25 16:35:11 UTC
When I try to install app-misc/anki, I got:

```
[blocks B      ] sys-apps/yarn ("sys-apps/yarn" is soft blocking net-libs/nodejs-22.10.0)
```

According to https://yarnpkg.com/corepack, `corepack enable` is the recommend way to install yarn now.

I tried remove yarn from anki's ebuild, and setup yarn with corepack for portage user, it's does work. But that requires manual setup and read/write outside sandbox, it's just a workaround, not a real solution.

Is that a better way to handle this?
Comment 1 Lucio Sauer 2024-11-26 21:31:52 UTC
Created attachment 912206 [details, diff]
Tentative patch that multiple packages to provide /usr/bin/yarn

Thanks for the report! Can you confirm or deny that you've got net-libs/nodejs[corepack] installed on your system? What manual setup was needed to succeed in installing the package?

> I tried remove yarn from anki's ebuild, and setup yarn with corepack for portage user, it's does work. [...]
> Is that a better way to handle this?
Yes, Anki shouldn't care if net-libs/nodejs[corepack] or sys-apps/yarn provides /usr/bin/yarn. I can provide a definitive patch by tomorrow evening.

In the meantime, anyone with this issue could try to either:
- install >=net-libs/nodejs-20.12.1[-corepack] or
- apply the attached patch
and then try to build Anki.
Comment 2 OwenJia 2024-11-27 06:17:03 UTC
(In reply to Lucio Sauer from comment #1)
> Thanks for the report! Can you confirm or deny that you've got
> net-libs/nodejs[corepack] installed on your system? What manual setup was
> needed to succeed in installing the package?
 
I do have net-libs/nodejs[corepack] installed:
```
$ equery u net-libs/nodejs
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for net-libs/nodejs-22.4.1-r1:
 U I
 + + corepack           : Enable the experimental corepack package management tool
<...>
 + + npm                : Enable NPM package manager
<...>
```


Corepack seems will install yarn inside user home, I do got a `/user/bin/yarn` executable file after install nodejs w/ corepack use flag enabled, but it is just a wrapper, so I setup yarn with this command:
```
sudo -u portage corepack prepare yarn@stable --activate
```


After that command, I got this on portage user's home directory:
```
$ tree --dirsfirst /var/lib/portage/home/.cache
/var/lib/portage/home/.cache
└── node
    └── corepack
        ├── v1
        │   └── yarn
        │       └── 4.5.3
        │           └── yarn.js
        └── lastKnownGood.json

6 directories, 2 files
```


And then try build anki with `ebuild /var/db/repos/gentoo/app-misc/anki/anki-24.06.3-r2.ebuild compile`, it's works.
Comment 3 Lucio Sauer 2024-11-27 23:07:50 UTC
> - apply the attached patch
Hmm, so this doesn't resolve the issue as I had hoped.  I have yet to find a way to activate the Yarn wrapper provided by nodejs[corepack], without it accessing the network to download the required tarball.  While I could provide it in SRC_URI, that would pin Yarn to a specific version for no reason.

More generally, the setup for offline workflows as described in
https://github.com/nodejs/corepack/tree/main?tab=readme-ov-file#offline-workflow
should rather be adopted into an eclass[1] to avoid code duplication, because modern Yarn (>1) is apparently supposed to be installed per-package rather than globally.

IMO, it's unfortunate that net-libs/nodejs[corepack] installs the Yarn wrapper globally and thus blocks sys-apps/yarn, when the former isn't really offline-only compatible at the moment.

[1]: See also https://github.com/gentoo/gentoo/pull/33426