bun icon indicating copy to clipboard operation
bun copied to clipboard

bun update does not update package.json

Open Dhruv-Garg79 opened this issue 2 years ago • 31 comments

What version of Bun is running?

1.0.2

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

run bun update in any node project with bun as a package manager

What is the expected behavior?

when we run bun update, it should update all the dependencies in the package.json.

What do you see instead?

when we run bun update, it shows updated dependencies in the terminal and indentation of package.json changes without change to the dependency version

Additional information

No response

Dhruv-Garg79 avatar Sep 21 '23 10:09 Dhruv-Garg79

Related to

  • https://github.com/oven-sh/bun/issues/5512
  • https://github.com/oven-sh/bun/issues/4312

Hanaasagi avatar Sep 21 '23 10:09 Hanaasagi

+1 for this task. I am using bun in production already, just had to manually check the package.json for outdated lines, even though the modules are acutally updated by bun

sindelio avatar Nov 13 '23 17:11 sindelio

any ETA for the fix?

voltuer avatar Dec 20 '23 03:12 voltuer

I have this issue as well. Using Bun 1.0.22. Windows WSL.

barziahmed avatar Jan 14 '24 12:01 barziahmed

1+ priority pls.

barziahmed avatar Jan 14 '24 17:01 barziahmed

+1 priority

sindelio avatar Jan 15 '24 16:01 sindelio

+1 priority

dreyfus92 avatar Jan 16 '24 06:01 dreyfus92

Also agree on priority, really stopping me from moving to bun on some projects

drinkius avatar Jan 16 '24 06:01 drinkius

But is this wanted behaviour ? Package.json has the version constraints , and an update will update them within those constraints. With npm, the only thing that's changing is the lock file.

I don't get what should change in the package.json when running bun update?

jorismak avatar Jan 17 '24 08:01 jorismak

But is this wanted behaviour ? Package.json has the version constraints , and an update will update them within those constraints. With npm, the only thing that's changing is the lock file.

I don't get what should change in the package.json when running bun update?

If you've used yarn before, the equivalent command would update these constraints to the latest. It's a nice QoL helper that ensures that your project is on the latest version for every dependency.

winstxnhdw avatar Jan 21 '24 09:01 winstxnhdw

Have the same issue. We need a command for updating versions in package.json too

malinindev avatar Jan 21 '24 09:01 malinindev

Sounds confusing, and kinda defeating of the whole "version constraints and lockfile" idea. I'm sure it has its place, not arguing against that.

Just surprised. It's not what almost every other package manager does, in JS or other languages. "Install" follows the lockfile if available, or creates/amends it. "Update" takes the latest versions available, within the constraints mentioned in de package.json.

Ignoring the version constraints in package.json is not what npm does, pnpm does and in other languages. And sounds confusion , why else are the constraints there? I must be missing something.

If you dont want version constraints and want to take new major versions or whatever, just name them "*" or something in package.json?

jorismak avatar Jan 21 '24 09:01 jorismak

It’s not confusing. People want to see what version of the package they are on without sieving through the lockfiles. It also makes it a lot easier to freeze the dependency when we eventually hit an issue with the latest version.

Btw pnpm update —latest exists too.

winstxnhdw avatar Jan 21 '24 09:01 winstxnhdw

So, I'm reading if yarn really does something different to other package managers. And from what I see from the docs there isn't a yarn update. It was first yarn upgrade and it's now yarn up.

So, hear me out. There is a reason - I think - that yarn didn't choose the same update command name. They knew that if they have different semantics or the command does things differently, it shouldn't have the same name.

I'm not saying that the functionality you people want shouldn't exist. Not at all. But - the pnpm command above is a good example - it should be a flag or a different command, not just 'update'. Because there is a different expectation compared to saying 'bun update'.

If you name the command the same as npm update, it should behave pretty much the same. And every kind of extra functionality should be a flag or a different command name.

The package-manager of course doesn't have to be an exact clone from the npm functionality, that is for the bun people to decide.

This might be of course my bubble, but I would not expect bun - or any other package manager - to adjust the main JSON package file from running update without anything extra. And I guess if way more people expected that, there would be more traffic to this topic.

So… in my humble opinion, just from the convention set for tools like npm, pnpm, composer and probably others… the update command should not touch package.json, only the lock file. Make a different command or add a flag if different behaviour is changed, like locking things in place (but you do you really do that for all dependencies listed??) or updating the version constraints to take later versions if they are available (and then testing later if they work or code needs changing).

People want to see what version of the package they are on without sieving through the lockfiles. That's what npm list or pnpm list are for. Bun choose to make the lock file binary even (but in a way it can dump it human-readable quickly). People might wait for bun to have a bun list (it's reserved, so it might come). If you prefer to use the package.json file differently, then you do you. I'm not telling anyone how to use tools or not. But I do advise the bun team to use a flag or different command for that functionality and not make it the default behaviour for bun update.

The description for bun update was at one point in time "Update outdated dependencies and update package.json", but the "and update package.json" part has been removed.

From what's currently in the bun update --help output, it IS confusing that it lists --save as being active by default and listed as 'Save to package.json'. But that is more used for bun install and bun add, that if you add a dependency it will update package.json. (From the old --save and --save-dev npm flags).

So. there is some information in the bun help output that contradicts the current behaviour. So I guess it's up to the bun team to decide what they actually want the command to do, and then fix the --help output or update the behaviour ;).

But I know a lot of people will be scratching their heads when bun update suddenly starts making changes to package.json and ignoring the version constraints in there.

jorismak avatar Jan 21 '24 10:01 jorismak

I agree that it should be a flag like bun update --latest as well. Unfortunately, right now bun update --save doesn't work as expected either.

winstxnhdw avatar Jan 21 '24 11:01 winstxnhdw

1+ priority pls.

federicofazzeri avatar Jan 25 '24 15:01 federicofazzeri

this project should never had released a 1.0 version, it totally lacks of real-world testing, i see a lot of issues in github from people who can't achieve basic Node/npm/pnpm things and, just like this one, are completely ignored even after 4 months

voltuer avatar Jan 28 '24 16:01 voltuer

The team has a different road map compared to what you find important. It happens . Jared already mentioned he thinks this is important, they just have different things to do first, for whatever reason. Accept that, please .

And like is mentioned here (by me? Maybe others ) is that updating the version constraints file while doing update isn't standard at all .

On Sun, Jan 28, 2024, 17:40 sebolio @.***> wrote:

this project should never had released a 1.0 version, it totally lacks of real-world testing, i see a lot of issues in github from people who can't achieve basic Node/npm/pnpm things and, just like this one, are completely ignored even after 4 months

— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/5856#issuecomment-1913655364, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMD2DRRAD3PY33PZKUDTGDYQZ5PVAVCNFSM6AAAAAA5BJIMLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGY2TKMZWGQ . You are receiving this because you commented.Message ID: @.***>

jorismak avatar Jan 28 '24 16:01 jorismak

Any update?

sovetski avatar Mar 05 '24 19:03 sovetski

And like is mentioned here (by me? Maybe others ) is that updating the version constraints file while doing update isn't standard at all .

then add an "upgrade" command like other managers do? come on, it's been 6 months

voltuer avatar Mar 15 '24 14:03 voltuer

This is such an essential tooling feature. Let's prioritize this a bit higher, please?

adiologydev avatar Mar 16 '24 10:03 adiologydev

Still exists on 1.0.33.

jizhi0v0 avatar Mar 20 '24 06:03 jizhi0v0

We will fix this a little bit after v1.1. The team is focused on shipping Windows support right now, and we're so close.

Jarred-Sumner avatar Mar 20 '24 07:03 Jarred-Sumner

We will fix this a little bit after v1.1. The team is focused on shipping Windows support right now, and we're so close.

Good job!

jizhi0v0 avatar Mar 20 '24 07:03 jizhi0v0

Still exists on 1.0.33.

+1 priority

Confucian-e avatar Mar 25 '24 08:03 Confucian-e

+1 priority really need it

garyellow avatar Mar 25 '24 17:03 garyellow

+1 on this

itsjoeoui avatar Apr 01 '24 21:04 itsjoeoui

I would argue that updating a package in the bun lockfile and not reflecting that in package.json is non-intuitive, as it effectively creates a mismatch between the codified system of record (what you think is running) and what's actually running.

If I run bun update jsdom I would expect it to update that package to the latest version and save that version to my package manifest.

If Bun does require a --save flag, please include that info in the response after running the update command so people know that the updates were not saved as they probably expected they would be.

jgentes avatar Apr 06 '24 12:04 jgentes

Upvoting this one more time! I'm already running Bun in production, having to keep track of the package versions is not a great developer experience.

sindelio avatar Apr 06 '24 17:04 sindelio

+1 priority

kingkong404 avatar Apr 08 '24 08:04 kingkong404