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

yarn --ignore-optional does not work properly #5878

Open
quinn opened this issue May 24, 2018 · 10 comments
Open

yarn --ignore-optional does not work properly #5878

quinn opened this issue May 24, 2018 · 10 comments

Comments

@quinn
Copy link

quinn commented May 24, 2018

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

What is the current behavior?
if i run yarn --ignore-optional somepackage I will get an error and unable to install somepackage if it depends on a private dependency that has been marked as optional.

If the current behavior is a bug, please provide the steps to reproduce.
yarn add --ignore-optional wix-storybook-utils

What is the expected behavior?
installs the package. Saves the pref so other people can install it too by running yarn install.

Please mention your node.js, yarn and operating system version.
OS X, yarn 1.6.0, node v9.11.1

@ghost ghost assigned rally25rs May 24, 2018
@ghost ghost added the triaged label May 24, 2018
@rally25rs
Copy link
Contributor

Yarn still has to be able to pull the metadata for the package to determine where it would be installed in node_modules if it were there and put it in the lockfile and get hoisting correct. This is basically the same as yarn install --prod still querying devDependencies. This is pretty much as-designed in yarn's scheme of making builds deterministic.

npm will completely ignore them, but also means npm is not deterministic (the result of an install may have different versions or hoist locations if the optional package was or wasn't available), so if this is a deal-breaker for you, you might actually want to use npm instead.

@rally25rs
Copy link
Contributor

For reference, #3630

That issue was left open, so maybe we should with this one too. Although "fixing" it would, I think, fundamentally break deterministic builds and it unlikely to actually change.

@quinn
Copy link
Author

quinn commented May 24, 2018

@rally25rs i hear you on it breaking deterministic builds, thats why i think the pref should be saved per package (somehow, maybe in lock file). That way if optionals are ignored, they are ignored forever, and if the pref changes it would require dependencies to be resolved again. I think this would still preserve the goals of yarn and still allow me to install the package i want to install :)

@quinn
Copy link
Author

quinn commented May 24, 2018

@rally25rs so the point i'm making is that no-optional wouldn't just not install it, but completely exclude it from the build.

@tmsdnl
Copy link

tmsdnl commented Jul 25, 2018

Hi

Adding to the thread.

I'm behind a corporate firewall, experiencing a somewhat similar problem when trying to add a global package.

Executing:
yarn global add pm2 || yarn global add --ignore-optional pm2

Results in:
error An unexpected error occurred: "https://tgz.pm2.io/gkt-1.0.0.tgz: Request failed \"403 Forbidden\"".

Environment:
OSX, Yarn 1.7.0, Node v8.11.2 (LTS)

Workaround:
npm install -g pm2

@quinn
Copy link
Author

quinn commented Jul 30, 2018

Yeah, I still don't think the statement "fundamentally breaks deterministic builds" makes sense. This is an optional package, all of the software can function without this package in perpetuity. If you want to permanently exclude this optional package, there is no reason to resolve it.

@jeffrson
Copy link

Even if yarn tries to load metadata - in the end it shouldn't bail out with an error if it fails to do so for optional dependencies.

@jd-carroll
Copy link

It would be nice to find away to make this work. I have a number of private packages that are used in a mono-repo which are not published to any repository any where. They are listed in the optionalDeps in the package.json but when I try to install in my Dockerfile it fails.

I feel like running the combination yarn install --production --ignore-optional should ignore any resolution errors and just move on.

Or even better a --ignore-resolution-errors flag.

@RobynLiu
Copy link

Any update?

@Pagebakers
Copy link

It would be nice to find away to make this work. I have a number of private packages that are used in a mono-repo which are not published to any repository any where. They are listed in the optionalDeps in the package.json but when I try to install in my Dockerfile it fails.

I feel like running the combination yarn install --production --ignore-optional should ignore any resolution errors and just move on.

Or even better a --ignore-resolution-errors flag.

Would love to see this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants