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

Bower doesn't update bower.json still #2035

Closed
jonathansolorzn opened this issue Nov 23, 2015 · 14 comments
Closed

Bower doesn't update bower.json still #2035

jonathansolorzn opened this issue Nov 23, 2015 · 14 comments

Comments

@jonathansolorzn
Copy link

This might have been asked before, but, why bower update --save doesn't update bower.json? Or what is the right way to update the dependencies to the latest version?

@pertrai1
Copy link
Contributor

@FeNiiXX What I just saw doing a test and reading the API, I needed to update the bower.json and then run bower update. The steps I took to test:

  • I added underscore library from npm install underscore --save
  • I then changed the version in bower.json to a lesser version
  • I then tried to update using bower update underscore#1.8.3 -F but did not change bower.json
  • I went inside of bower.json and changed to 1.8.3 and then ran bower update
  • When I made the change in bower.json and then ran bower update, the package did change in bower.jsonz

I did not see anywhere in the API docs that shows where you can update a package straight from the command line without making a change to the bower.json file first.

@jonathansolorzn
Copy link
Author

Isn't it odd @pertrai1 ? Bower should have a command to update all depencies to the latest version:s

@FrancescoRizzi
Copy link

Hi, I'm fairly new to using bower myself, so I might be wrong, but when you said:

I then tried to update using bower update underscore#1.8.3 -F

Shouldn't you have included/added the --save flag to expect bower to update the bower.json file? Without it, I think you're saying "force update the underscore library to v.1.8.3 (but don't save this detail to the bower.json file)"

@pertrai1
Copy link
Contributor

@FrancescoRizzi Thanks for sharing that. I did not see anything in the docs that said that one needs to use the --save flag when doing an update. Is this the case @sheerun ? If it is, this should be added to the docs so one will know that they need to add this when running the bower update command.

@sheerun
Copy link
Contributor

sheerun commented Nov 25, 2015

I really don't know how bower update works now. But I'm pretty sure it doesn't do what it should. It would be nice if someone experimented with it and documented results in Wiki.

@pertrai1
Copy link
Contributor

@sheerun I am going to assign this to myself to experiment and document.

@pertrai1 pertrai1 self-assigned this Nov 25, 2015
@ManasJayanth
Copy link
Member

Documenting my observations here. I installed underscore using bower install underscore#1.8.2 --save and did the following.

  • Ran bower update. Installs the same version again. No changes with --save option.
  • Ran bower install. Command simply terminates. No re-download or installation from cache

I then manually update the underscore version to 1.8.3 in package,json.

  • Ran bower update. Installs the new version of underscore

Installed back underscore 1.8.2 version again without touching bower.json (So the version is still 1.8.3 in package.json but 1.8.2 in bower_components folder.)

  • Ran bower install. Same behavior as bower update - installed the new version.

Given the same state of bower_components folder, install and update commands behave the same.

Ideally, I feel update should update the existing components.

@pertrai1
Copy link
Contributor

Thank you @prometheansacrifice for the detailed reproduction steps. I am looking into the update command and the config options today and tomorrow. Right now it is not setup to update unless there is a change in the .json file that it reads for any changes to the dependencies.

@pertrai1
Copy link
Contributor

@sheerun I started working on the update command by adding a simple abbreviation bower u command. Will continue to look at the command and the options. #2055

@sheerun
Copy link
Contributor

sheerun commented Nov 27, 2015

@FeNiiXX Does npm update update package.json?

@jonathansolorzn
Copy link
Author

Yes, it does @sheerun if there's an ~ before the version of the dependecy, but I'm not sure if --save is needed

@contolini
Copy link
Member

@sheerun @FeNiiXX npm update doesn't write anything to package.json unless the --save flag is passed:

When you want to update a package and save the new version as the minimum required dependency in package.json, you can use npm update -S or npm update --save

As folks have mentioned here, bower update never updates bower.json, even if you pass --save. This behavior is unexpected and IMO it should mimic npm by updating bower.json if --save is specified.

@contolini
Copy link
Member

@prometheansacrifice Thanks for documenting this. In your scenario, update is working as expected.

Similar to npm, bower's update respects semver. So if you have underscore pegged at 1.8.2 in bower.json, it won't be updated. However, if you save it as ~1.8.2 (bower install underscore#~1.8.2 --save) and then run bower update, it will update it to the latest version between 1.8.2 and 1.9.0 (which happens to be 1.8.3).

@contolini
Copy link
Member

#2062 introduces the --save flag to bower update.

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

No branches or pull requests

7 participants