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

TypeError: Reduce of empty array with no initial value #5876

Closed
spalger opened this issue May 24, 2018 · 28 comments · Fixed by #5879
Closed

TypeError: Reduce of empty array with no initial value #5876

spalger opened this issue May 24, 2018 · 28 comments · Fixed by #5879
Assignees
Labels

Comments

@spalger
Copy link

spalger commented May 24, 2018

What is the current behavior? Installing dependencies fails with error An unexpected error occurred: "Reduce of empty array with no initial value".

If the current behavior is a bug, please provide the steps to reproduce.

This is the simplest reproduction I've been able to create. The result should look something like this: https://github.com/spalger/reproduce-issues/tree/master/yarn-reduce-of-empty-array-without-initial-value

error log: https://github.com/spalger/reproduce-issues/blob/master/yarn-reduce-of-empty-array-without-initial-value/bar/yarn-error.log

# create two packages
mkdir foo bar

# install `tree-kill` dependency in `foo`
cd foo && yarn init -y && yarn add tree-kill

# link to `foo` from bar
cd ../bar && yarn init -y && yarn add link:../foo

yarn add in bar should fail.

What is the expected behavior? yarn add should not fail with internal error

Please mention your node.js, yarn and operating system version.
node -v: v8.11.0
yarn -v: 1.7.0

@ghost ghost assigned arcanis May 24, 2018
@ghost ghost added the triaged label May 24, 2018
@spalger
Copy link
Author

spalger commented May 24, 2018

@bdwain
Copy link
Contributor

bdwain commented May 24, 2018

@spalger i can try to look into this tonight.

@bdwain
Copy link
Contributor

bdwain commented May 25, 2018

I think I've found this issue and I'll have a PR up tonight. cc @bestander

@bestander
Copy link
Member

ping me when PR is ready

@bdwain
Copy link
Contributor

bdwain commented May 25, 2018

@bestander #5879

@spalger
Copy link
Author

spalger commented May 25, 2018

Thanks @bestander and @bdwain!

@nothingismagick
Copy link

Any idea when this will land as a point release like 1.7.1 ? i just got bit by the link problem...

@cooperka
Copy link

Temporary workaround until patch release (works for me): remove node_modules, install without links, then add links back.

rm -rf node_modules
yarn
yarn link myProject

@arcanis
Copy link
Member

arcanis commented May 25, 2018 via email

@nothingismagick
Copy link

nothingismagick commented May 25, 2018

I already did this (on MacOS)

$ brew unlink yarn

$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/76215230de5f7f7bee2cfcdd7185cf49d949862d/Formula/yarn.rb

$ brew switch yarn 1.6.0_1

@MikeTaylor
Copy link

MikeTaylor commented Jun 8, 2018

Many thanks to @nothingismagick for the workaround.

I don't understand how a bug this serious made it into a release of mission-critical software like Yarn.

@nothingismagick
Copy link

Yeah, its kind of a weird situation. Over at https://github.com/quasarframework/quasar I have been championing Yarn - especially for our devs working on core. Being able to so effortlessly link (and not accidentally destroy the linked folder!!!) with yarn is a huge selling point. Telling them to downgrade makes me feel silly. :(

@nothingismagick
Copy link

By the way, there are several ways to "link", and the one I currently prefer is e.g.:

yarn add "quasar-cli@link:../quasar-cli"

This way I don't have to run the link command in the quasar-cli folder and the target folder. This is nice when you need to have multiple versions and DON'T want a global link polluting your work.

@MikeTaylor
Copy link

Oh, thanks, I didn't know about that. (We have almost entirely managed to stop using yarn link, finding that workspaces do most of what we need.)

@happycollision
Copy link

Perhaps Yarn shouldn't encourage people to upgrade to a new major version until it has been out a while? I only upgraded because Yarn suggested it. Now my projects are broken.

Though, I'm sure this is a rare thing that such a big feature goes haywire and it gets released that way.

@james-rabbit
Copy link

Will there be a point release 1.7.1 or is 1.8.0 coming too soon?
Anyone in my team that starts with or updates to the latest stable yarn runs into this issue.

@arcanis
Copy link
Member

arcanis commented Jun 26, 2018

Yarn 1.8 has been released two weeks ago: https://github.com/yarnpkg/yarn/releases

I'll move it to stable tomorrow since we haven't got critical reports yet, but you can already install it from various ways (for example with npm, npm install -g yarn@rc should do the trick).

@happycollision
Copy link

happycollision commented Jun 29, 2018

According to https://yarnpkg.com/en/docs/install#mac-rc, 1.7.0 is still the release candidate. (It's also the stable version of course.)

But yes, RC is 1.8.0 on NPM.

@alex-wilmer
Copy link

This is kind of silly but it's working for me

npx yarn@rc add <package>

@james-rabbit
Copy link

@arcanis any update on moving yarn 1.8 to stable?

@scottschup
Copy link

Others recommended a rm -rf node_modules and then re-yarn-install. But I just had to

yarn unlink PACKAGE
yarn
yarn link PACKAGE

@BiosBoy
Copy link

BiosBoy commented Jul 12, 2018

I cannot install last yarn 1.8.0 from choco install yarn@1.8.0 or choco install yarn@rc - error: package did not found. Also if I try to make it throw npm install -g yarn@rc I gets installed yarn v.1.8.0 on my machine, but really, when I try to run yarn info or yarn versions - I see yarn v.1.7.0 in log. Miracle...

@happycollision
Copy link

happycollision commented Jul 12, 2018 via email

@josselinlbe
Copy link

@arcanis thanks ! 👍

@ghost
Copy link

ghost commented Jul 17, 2018

as a workaround you can do (on MacOS) until 1.8.0 lands in brew

brew unlink yarn
brew install https://raw.githubusercontent.com/joscha/homebrew-core/a6f904aac4df702cfff11d94d5fd257f841bffa2/Formula/yarn.rb

@mvu02
Copy link

mvu02 commented Jul 17, 2018

@arcanis v1.7.0 is still listed as the stable version and v1.8.0 seems to have been taken off the RC list on https://yarnpkg.com/en/docs/install#windows-stable. Is there a window installer I can get for v1.8.0 somewhere?

tylersmalley pushed a commit to tylersmalley/kibana that referenced this issue Jul 23, 2018
Due to a [bug in yarn 1.7.0](yarnpkg/yarn#5876) you can't use that version of Yarn

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
@rankun203
Copy link

The latest version of yarn is 1.9.2 already, just upgrade your yarn.

https://yarnpkg.com/en/package/yarn

@saarsalu
Copy link

saarsalu commented Jan 9, 2020

hey i got 2 times today on bot.binary.com
using a robot error
Reduce an empty array with no initial value

72040927-bfb37c80-32b2-11ea-9ac3-c86e95b63d0a

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

Successfully merging a pull request may close this issue.