-
Notifications
You must be signed in to change notification settings - Fork 604
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
[rush] Optional dependencies not handled properly #761
Comments
Are you able to reproduce the issue using NPM 4.5.0? NPM 5.x and 6.x have various known bugs that sometimes cause trouble for Rush. |
Just tried it with npm 4.5.0 and it works fine! |
I need to update the documentation to recommend NPM 4.5.0. Longer term, we need to figure out what to do about these NPM issues. If they cannot be fixed, perhaps we should support Yarn instead of NPM. |
FYI Yarn is now supported as of Rush 5.1.0. |
I'm having an identical issue with yarn. The dependencies get skipped as optional, and then webpack throws on fsevents and a few other osx specific packages. Is there a way to force rush to install these? I set I'm seeing
|
In the old days, we encountered this problem: If I ran This meant that the contents of our shrinkwrap file depended on which OS was used to run Looking at the code, this flag seems to be added for PNPM and NPM but not Yarn. But then But first, I'm curious about what package managers are doing in the year 2018. If we're lucky, perhaps PNPM/NPM/Yarn have all evolved to have the correct design, i.e. including optional dependencies in the shrinkwrap file even if they were not installed. If so, then we could remove this workaround entirely. Do you happen to know the answer? :-P |
Yarn now obeys the skip optional dependencies command. It will read it out of the npmrc/yarnrc as well. https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-ignore-optional I understand why we wouldn't want them in rush's lock file, but they at least need to locally install so that webpack will run on OSX. I'd argue that because determinism and reliability are more important, it's better to ALWAYS install optional dependencies even if they won't be used. That way it is the same everywhere. This webpack stuff won't even run on OSX without the "optional" modules. |
Something about your setup requires an optional dependency? How does that work? (We use webpack on both Mac/PC and we haven't had this issue. Usually the optional dependencies are just for extra features or optimizations.) |
Digging a little more, it looks like it's because of a package that declares its dependencies wrong. I submitted a fix request. TritonDataCenter/node-sshpk#53 In the mean time, wouldn't it be good if there were a way for rush to link optional dependencies? |
I just tried an experiment with the various package managers on a Windows PC: I installed dirgen which depends on fsevents which has NPM 3.10.8
NPM 6.4.1
Yarn 1.10.1
PNPM 2.16.3:
So old NPM releases are the only obstacle to eliminating |
NPM 4.5.0
Darn... |
So I think what we should do is:
I marked this as "help wanted" because this is a pretty easy fix. But if nobody in the community volunteers, then I'll see if someone from our team can do it. |
I'd like to work on this; can probably start working on a fix tomorrow or Sunday. Looking forward to being able to run |
Sorry, I didn't get around to it on the weekend and probably won't have time during this week. Someone else can start tackling this if they like, otherwise I think I can take a look this coming weekend. |
I got around to making the fix tonight: #878 The changes are fewer than I expected, so I feel like I'm missing something 😅 |
Awesome! Thanks a lot for fixing this!
Hmm... no, it looks reasonable to me. If you tested it and it works, that's good enough for me! |
So i am hitting this issue but with latest pnpm. in my own package.json we have a optional dep that only for windows, but on windows it still does not install |
Same for OS X with pnpm, my use case is putting one dependency in
|
@jcgertig Could you open a new issue with repro steps? |
We should document this, but generally we try to avoid putting settings in
@wasd171 Can you explain the idea behind this in more detail (maybe with an example)? I have not seen this practice before. If you are simply trying to reduce the set of that dependencies deployed to Docker, you can use rush deploy for that. |
@octogonz |
@wasd171 My understanding of As far as But it sounds like you want a way for |
@octogonz yes, sounds like a better use case for the installation variants. I was mostly confused by the |
When I try to use
rush
on a package that depends on webpack on a laptop that runs Linux I get the following error:The project depends (transitively, through webpack) on
fsevents
which is a package that can only be installed on a Mac.The shrinkwrap file at
common/config/rush/npm-shrinkwrap.json
correctly marksfsevents
as optional.My minimal test case:
The text was updated successfully, but these errors were encountered: