Skip to content
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

Incompatible platform error for optional dependency with resolution entry #6834

Open
net opened this issue Dec 17, 2018 · 10 comments
Open

Incompatible platform error for optional dependency with resolution entry #6834

net opened this issue Dec 17, 2018 · 10 comments
Assignees
Labels

Comments

@net
Copy link

net commented Dec 17, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
yarn errors when a resolution for an optional dependency is specified if run on an incompatable platform.

fsevents is only available on macOS (darwin):

"resolutions": {
  "**/fsevents": ">=1.2.4"
}
root@fbcb6ce8bfb9:/# yarn
yarn install v1.12.3
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
error fsevents@2.0.1: The platform "linux" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Without the above resolutions yarn runs without error:

root@fbcb6ce8bfb9:/# yarn
yarn install v1.12.3
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.1.2: The platform "linux" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...

What is the expected behavior?
No incompatibility errors.

Please mention your node.js, yarn and operating system version.
node v9.8.0, yarn 1.12.3, ubuntu 16.04.2 docker image

@ghost ghost assigned imsnif Dec 17, 2018
@ghost ghost added the triaged label Dec 17, 2018
@rally25rs
Copy link
Contributor

This sounds familiar... I think there is an open issue for this, but I can't seem to find it.

IIRC yarn adds the resolution as a hard-coded normal dependency first before checking the rest of the deps. Then it finds the optional dep and replaces it with the existing (non-optional) resolution dep.

@rally25rs rally25rs added cat-bug and removed triaged labels Dec 20, 2018
@byzyk
Copy link

byzyk commented Jul 8, 2019

Is there any update on this? I can help with the PR, what would be the proper solution to this?

@BYK
Copy link
Member

BYK commented Jul 8, 2019

I think this is fixed with #7273, right? /cc @kaylie-alexa

@jordoh
Copy link

jordoh commented Aug 2, 2019

This sounds familiar... I think there is an open issue for this, but I can't seem to find it.

Are you thinking of #2437?

@HosseinAgha
Copy link

@BYK I can confirm this is still not fixed using yarn v1.17.3

@yharaskrik
Copy link

This is happening for me in yarn v1.19.1

@beaulac
Copy link

beaulac commented Nov 27, 2019

Also seeing this on yarn v1.19.2

#7273 Seems to only have fixed the issue for direct optional dependencies

The problem occurs when transitive dependencies are optional, so this test fails

This is likely the most common usage of resolutions – if it's a direct dependency, why use resolutions instead of just modifying the version in dependencies?

Workaround is to explicitly define the transitive optional dependency at the root, e.g:

{
  "resolutions": {
    "**/fsevents": ">=1.2.4"
  },
  "optionalDependencies": {
    "fsevents": "*"
  }
}

Then yarn --ignore-optional behaves as expected.

styk-tv added a commit to MusicAsCode/set-player that referenced this issue Dec 30, 2019
yarn issue with optional dependencies (mac yes, linux no)
yarnpkg/yarn#6834

related to enforced fsevents version
timja pushed a commit to hmcts/cnp-jenkins-library that referenced this issue Feb 19, 2020
I'm having a nightmare of a time with fsevents
One fix is to force upgrade it, but then optional dependencies don't work right,

Forcing it to be optional works but it doesn't work OOTB, needs this flag,
ref:
yarnpkg/yarn#6834
yarnpkg/yarn#6834 (comment)
timja pushed a commit to hmcts/cnp-jenkins-library that referenced this issue Feb 19, 2020
I'm having a nightmare of a time with fsevents
One fix is to force upgrade it, but then optional dependencies don't work right,

Forcing it to be optional works but it doesn't work OOTB, needs this flag,
ref:
yarnpkg/yarn#6834
yarnpkg/yarn#6834 (comment)
@KrishnaPuppala
Copy link

Hi, do we have a solution for this? We are running the same issue for node 12 and fsevents 1.2.9. Works on mac os but incompatible with linux environments.

@xMort
Copy link

xMort commented Mar 24, 2020

I can confirm this bug on node 12.16.1, yarn 1.22.4 with fsevents 1.2.9+

@yharaskrik
Copy link

yharaskrik commented Mar 24, 2020

For anyone experiencing this issue I have made a script we have been using for months with success. It runs on our CI prior to running yarn install.

sed -ie 's/\"\*\*\/fsevents\": \"^1.2.9\",//g' package.json

START_NUM=$(awk '/fsevents@/{print NR; exit }' yarn.lock)
echo $START_NUM
END_NUM=$(($START_NUM + 7))
echo $END_NUM
sed -i.bak -e $START_NUM','$END_NUM'd' yarn.lock

It may need some tweaks for your specific use case but it has helped us get around the fsevents error on our CI (it isn't an issue locally as we all use Macs)

It will remove the fsevents entry in your package json and yarn lock file.

VladyslavBondarenko added a commit to salemove/react-intl-tel-input that referenced this issue Aug 31, 2023
Fsevents is used in webpack. Updating it to the version that uses
non-vulnerable fsevents can require some effort.
To quickly address the issue, used yarn resolutions to resolve
fsevents to non-vulnerable version.

Yarn has [an issue](yarnpkg/yarn#6834)
that resolutions make optional dependencies non-optional.
Seeting fsevents as an optional dependency.
VladyslavBondarenko added a commit to salemove/react-intl-tel-input that referenced this issue Aug 31, 2023
Fsevents is used in webpack. Updating it to the version that uses
non-vulnerable fsevents can require some effort.
To quickly address the issue, used yarn resolutions to resolve
fsevents to non-vulnerable version.

Yarn has [an issue](yarnpkg/yarn#6834)
that resolutions make optional dependencies non-optional.
Seeting fsevents as an optional dependency.
VladyslavBondarenko added a commit to salemove/react-intl-tel-input that referenced this issue Sep 5, 2023
Fsevents is used in webpack. Updating it to the version that uses
non-vulnerable fsevents can require some effort.
To quickly address the issue, used yarn resolutions to resolve
fsevents to non-vulnerable version. Could resolve to 1.2.11,
resolving to ~2.3.2 only because visitor-app where
where react-intl-tel-input already uses ~2.3.2, so this change
won't add any new dependencies there.

Yarn has [an issue](yarnpkg/yarn#6834)
that resolutions make optional dependencies non-optional.
Seeting fsevents as an optional dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests