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 install removes everything from bower_components directory #616

Closed
skuridin opened this issue Oct 11, 2016 · 41 comments
Closed

Yarn install removes everything from bower_components directory #616

skuridin opened this issue Oct 11, 2016 · 41 comments

Comments

@skuridin
Copy link

skuridin commented Oct 11, 2016

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

What is the current behavior?
Removes everything from bower_components directory

If the current behavior is a bug, please provide the steps to reproduce.
In a project, that uses both npm and bower, run yarn

What is the expected behavior?
Install missed modules to node_modules and do nothing with bower_components

Please mention your node.js, yarn and operating system version.
macOS 10.12, node 6.6.0, npm 3.10.3, yarn 0.15.1

@sebmck
Copy link
Contributor

sebmck commented Oct 11, 2016

Yarn is actually a drop in replacement for bother Bower and npm. Are we correctly populating bower_components? Can you check node_modules to see if we're accidentally putting them in there instead?

@skuridin
Copy link
Author

Can you check node_modules to see if we're accidentally putting them in there instead?

Couldn't find them in node_modules.

git status after executing yarn (it removes event .gitignore):

    deleted:    bower_components/.gitignore
    deleted:    bower_components/jquery-ujs/.bower.json
    deleted:    bower_components/jquery-ujs/CHANGELOG.md
    deleted:    bower_components/jquery-ujs/MIT-LICENSE.txt
    deleted:    bower_components/jquery-ujs/README.md
    deleted:    bower_components/jquery-ujs/bower.json
    deleted:    bower_components/jquery-ujs/src/rails.js
    deleted:    bower_components/jquery.payment/.bower.json
    deleted:    bower_components/jquery.payment/.gitignore
    deleted:    bower_components/jquery.payment/.travis.yml
    deleted:    bower_components/jquery.payment/Cakefile
    deleted:    bower_components/jquery.payment/LICENSE
    deleted:    bower_components/jquery.payment/README.md
    deleted:    bower_components/jquery.payment/bower.json
    deleted:    bower_components/jquery.payment/example/index.html
    deleted:    bower_components/jquery.payment/lib/jquery.payment.js
    deleted:    bower_components/jquery.payment/package.json
    deleted:    bower_components/jquery.payment/payment.jquery.json
    deleted:    bower_components/jquery.payment/src/jquery.payment.coffee
    deleted:    bower_components/jquery.payment/test/index.coffee

@jerguslejko
Copy link

@skuridin do they appear in the listing when you run yarn ls?

@nathanpalmer
Copy link

I'm running into the same issue. Once I run yarn and it installs or changes dependencies then bower_components is completely empty.

Looks like they are in node_modules instead.

image

After I run bower install again I get the dependency in bower_components (which is where ember-cli is looking for it.)

image

@RustyToms
Copy link
Contributor

RustyToms commented Oct 11, 2016

Same thing here, it appears that bower_components is completely emptied out. I see some of the files in the node_modules folder, but not the majority of them, matching what I see from yarn ls, I think it might be coincidence that some packages match? Running v0.15.1 on a mac.

If yarn interacts with bower, could that be in the documentation somewhere? I can't even find the word "bower" in the docs. And it only shows up in any description in the repo here

@skuridin
Copy link
Author

@skuridin do they appear in the listing when you run yarn ls?

nope

@RustyToms
Copy link
Contributor

I made a very simple repo to demonstrate this issue with a single bower.json and a single package.json dependency: https://github.com/RustyToms/yarn-issue-616

@RustyToms
Copy link
Contributor

What seems to be happening here is bower is being added as a registry. All the folders in the registries, including bower_components are being set as possibleExtraneous. Then, if those files weren't included in the files that yarn is building, they are deemed to be actually extraneous and are deleted.

The main problem seems to be that bower.json dependencies don't seem to be properly loaded into the set of dependencies that yarn is collecting.

@MaximRouiller
Copy link

Tried on our project.

We have a bower.json + package.json and we have the same behavior. We are also using .bowerrc (output to "libs" folder) and this folder also get removed.

As soon as this is fixed, we can transition on our team.

@ambirdsall
Copy link

Ran into a fairly weird version of this bug. My project doesn't use bower, but a collaborator used it once to install a dependency. They made a .bowerrc file like the following:

{
  "directory": "js/"
}

so that it would be installed in the js directory with the application code. I had moved the dependency to node_modules with the others, but forgot the .bowerrc file because it's hidden. Running yarn ended up deleting all of my application code; as there was no output indicating .bowerrc was being read, it took quite some time to figure a hidden file for a program that isn't part of my current workflow was to blame.

Deleting extraneous module locations makes a certain amount of sense, but doing so silently (a confirmation before delete would be ideal, but at least logging what's happening would have saved me a fair bit of time) is rather user-unfriendly—at least in edge cases like this one.

@kitsunde
Copy link

Since yarn 0.16 it's possible to hook in bower install and make this a bit less distracting while we wait for a proper fix. In package.json:

{
  "scripts": {
    "postinstall": "bower install"
  }
}

@warapitiya
Copy link

Same issue here.

yarn version 16.1
Ubuntu 16.04

@sebmck
Copy link
Contributor

sebmck commented Oct 26, 2016

We've removed support for Bower, see #1441.

@sebmck sebmck closed this as completed Oct 26, 2016
@linuxonrails
Copy link

Same issue here.

Why should I use only bower or yarn? why not both?!

I have (old) packages in bower_components/ directory and I want to replace npm with yarn (I can use npm with bower).

@gabrielkoerich
Copy link

You can use yarn and bower. We just have to wait for a new tag.

@mischah
Copy link

mischah commented Oct 26, 2016

Why should I use only bower or yarn? why not both?!

That will be possible with the next release of yarn because Yarn won’t take care of your Bower packages. See #1441

Tip: Use yarn install and define bower install as postinstall script in your package.json.

@linuxonrails
Copy link

OK! I'm sorry!!! 👍
Thanks!!!

@shafi49
Copy link

shafi49 commented Oct 28, 2016

I didn't expect this kind of behavior. I was excited about yarn. But after wasting half an hour figuring out where my bower_components go I gave up on yarn.

@Arrow7000
Copy link

Arrow7000 commented Oct 28, 2016

Out of curiosity, when will the next, non-bower_components-removing, version of Yarn be released?
Thanks

@jamesdixon
Copy link

bump

@sinedied
Copy link

sinedied commented Nov 3, 2016

Please publish the version that fixes bower, this is really blocking here :(

@omnisite
Copy link

omnisite commented Nov 3, 2016

Just use the workaround with postinstall. Works like a charm. Anyway: bower support will be dropped, so the workaround is your only option.

@elmariofredo
Copy link

elmariofredo commented Nov 3, 2016

@omnisite problem is that yarn add something will clean bower_components directory as well and workaround won't solve that

@omnisite
Copy link

omnisite commented Nov 3, 2016

Ah ok. Well, you can always just edit the package and bower json file. I know "add" is easier, but there is just not much choice if Yarn is dropping support for Bower.

@elmariofredo
Copy link

@omnisite you can do all sort of hacks like run yarn right after yarn add but that's not the point, as yarn is not supporting bower then it should not mess with bower_components folder and prevent a lot of confusion in Polymer and other bower infected communities all around the globe.

Therefore prompt release would be more than appreciated 😉

Thanks!

@omnisite
Copy link

omnisite commented Nov 3, 2016

@elmariofredo Yes, I agree. I was bummed also that it did not work out of the box. Still I can work with both with the workaround. And we have no idea when they will fix it.

@elmariofredo
Copy link

@omnisite sure just please mind that OSS is driven by community comments and stating

Works like a charm

is IMHO not exactly fitting this case

@sinedied
Copy link

sinedied commented Nov 3, 2016

@omnisite Your workaround does not work in my case, as bower dependencies are commited within the repo (we don't like to rely on the bower tool on each build as we had issues with it from time to time).

yarn deprecating bower support is just fine for me, as long as it does not mess with it.

@raucao
Copy link

raucao commented Nov 3, 2016

Also, it seems to be done already, so why not release?

https://github.com/yarnpkg/yarn/pulls?utf8=%E2%9C%93&q=is%3Apr%20is%3Aclosed%20bower

@dennisfrank
Copy link

dennisfrank commented Nov 11, 2016

Yes. It would be cool, if you could release yarn without bower support (and without messing with the bower_components dir).

I ran into this problem myself while traveling offline. yarn’s offline mode was the primary reason to use yarn in the first place. Without a local backup I had not been able to restore bower_components. This is serious. The workarounds from the comments above don’t work offline.

Thanks!

@patcoll
Copy link

patcoll commented Nov 11, 2016

@dennisfrank Thanks for saying that.

I'm tempted to offer a bounty for someone re-instating and completing bower support. It's still widely used, even if it is being deprecated in a lot of places. And its ability to have repeatable installs is very poor.

@barryvdh
Copy link

I don't think the biggest problem is missing Bower, it's the unexpected deletion of the bower directory :/

Not really sure why this isn't seen as a critical enough issue to release a new (minor) tag for, this can cause serious problems for someone who isn't using version control.

@dennisfrank
Copy link

@barryvdh Exactly. But even if you you use version control the bower directory often gets ignored on purpose.

@MaximRouiller
Copy link

Once this get published, I'm ditching npm for our team. Meanwhile? I'll wait,

@thetrevdev
Copy link

Not sure what is blocking the release or the target eta. With an early library like this it would be better to see them make changes faster. This has been sitting for a month.

@MaximRouiller
Copy link

No idea. In the mid time, this is preventing adoption.

@elmariofredo
Copy link

It's released with version 0.17.0 🎉

@cyyyu
Copy link

cyyyu commented Nov 15, 2016

YES. Version 0.17.0 have fixed this. Already upgraded.

@shafi49
Copy link

shafi49 commented Nov 15, 2016

yes... it is true guys. yarn is safe for bower users. thanks yarn team

@MaximRouiller
Copy link

MaximRouiller commented Nov 15, 2016

Updated yarn to latest with:

npm install -g yarn

Ran yarn --version and it resolved to 0.17.0.

Ran yarn on my solution and only detected 1 change: yarn.lock

You guys rock. We're putting a change in our backlog to change to yarn today. 😄

@MaximRouiller
Copy link

MaximRouiller commented Nov 15, 2016

out-npm

Original

Made with my awesome Paint skillz.

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