swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.72k stars 1.34k forks source link

Updating a single dependency seems to update all dependencies #5663

Open JetForMe opened 2 years ago

JetForMe commented 2 years ago

Description

I frequently want to update a single dependency, using swift package update <some package>. However, when I do this, it seems to visit every dependency, which takes a lot of time.

For example:

pi@furnace:~/furnace-controller $ swift package update SwiftMODBUS
Updating https://github.com/latencyzero/SwiftMODBUS
Updated https://github.com/latencyzero/SwiftMODBUS (0.97s)
Updating https://github.com/apple/swift-nio-extras.git
Updating https://github.com/apple/swift-crypto.git
Updating https://github.com/vapor/jwt.git
Updated https://github.com/apple/swift-crypto.git (0.89s)
Updating https://github.com/vapor/vapor.git
Updated https://github.com/apple/swift-nio-extras.git (0.89s)
Updated https://github.com/vapor/jwt.git (0.89s)
Updating https://github.com/vapor/sqlite-kit.git
Updating https://github.com/uraimo/SwiftyGPIO.git
Updated https://github.com/vapor/sqlite-kit.git (0.83s)
Updated https://github.com/uraimo/SwiftyGPIO.git (0.83s)
Updating https://github.com/vapor/sqlite-nio.git
Updating https://github.com/vapor/async-kit.git
Updated https://github.com/vapor/vapor.git (1.19s)
Updating https://github.com/vapor/routing-kit.git
Updated https://github.com/vapor/sqlite-nio.git (0.85s)
Updating https://github.com/apple/swift-collections.git
Updated https://github.com/vapor/async-kit.git (0.85s)
Updating https://github.com/apple/swift-metrics.git
Updated https://github.com/vapor/routing-kit.git (0.82s)
Updating https://github.com/mxcl/Path.swift.git
Updated https://github.com/apple/swift-collections.git (0.89s)
Updating https://github.com/vapor/sql-kit.git
Updated https://github.com/apple/swift-metrics.git (1.00s)
Updating https://github.com/swift-server/async-http-client.git
Updated https://github.com/mxcl/Path.swift.git (0.80s)
Updating https://github.com/vapor/fluent.git
Updated https://github.com/vapor/sql-kit.git (0.88s)
Updating https://github.com/apple/swift-numerics
Updated https://github.com/swift-server/async-http-client.git (0.91s)
Updating https://github.com/apple/swift-nio-transport-services.git
Updated https://github.com/vapor/fluent.git (1.06s)
Updating https://github.com/apple/swift-nio.git
Updated https://github.com/apple/swift-nio-transport-services.git (0.83s)
Updating https://github.com/apple/swift-algorithms.git
Updated https://github.com/apple/swift-numerics (1.04s)
Updating https://github.com/vapor/multipart-kit.git
Updated https://github.com/apple/swift-nio.git (1.18s)
Updating https://github.com/vapor/console-kit/
Updated https://github.com/vapor/multipart-kit.git (0.80s)
Updating https://github.com/vapor/jwt-kit.git
Updated https://github.com/apple/swift-algorithms.git (0.92s)
Updating https://github.com/vapor/websocket-kit.git
Updated https://github.com/vapor/console-kit/ (0.85s)
Updating https://github.com/swift-server/swift-backtrace.git
Updated https://github.com/vapor/jwt-kit.git (0.82s)
Updating https://github.com/vapor/fluent-kit.git
Updated https://github.com/vapor/websocket-kit.git (0.81s)
Updating https://github.com/apple/swift-nio-ssl.git
Updated https://github.com/swift-server/swift-backtrace.git (0.88s)
Updating https://github.com/vapor/fluent-sqlite-driver.git
Updated https://github.com/apple/swift-nio-ssl.git (0.91s)
Updating https://github.com/apple/swift-nio-http2.git
Updated https://github.com/vapor/fluent-kit.git (1.22s)
Updating https://github.com/apple/swift-log.git
Updated https://github.com/vapor/fluent-sqlite-driver.git (0.87s)
Updated https://github.com/apple/swift-nio-http2.git (0.88s)
Updated https://github.com/apple/swift-log.git (0.94s)
Computing version for https://github.com/mxcl/Path.swift.git
Computed https://github.com/mxcl/Path.swift.git at 1.4.0 (0.49s)
Computing version for https://github.com/uraimo/SwiftyGPIO.git
Computed https://github.com/uraimo/SwiftyGPIO.git at 1.3.9 (0.48s)
Computing version for https://github.com/vapor/websocket-kit.git
Computed https://github.com/vapor/websocket-kit.git at 2.5.0 (0.52s)
Computing version for https://github.com/vapor/vapor.git
Computed https://github.com/vapor/vapor.git at 4.62.1 (0.69s)
Computing version for https://github.com/vapor/jwt.git
Computed https://github.com/vapor/jwt.git at 4.2.1 (0.52s)
Computing version for https://github.com/vapor/fluent-sqlite-driver.git
Computed https://github.com/vapor/fluent-sqlite-driver.git at 4.2.0 (0.52s)
Computing version for https://github.com/vapor/fluent.git
Computed https://github.com/vapor/fluent.git at 4.4.0 (0.54s)
Computing version for https://github.com/vapor/console-kit/
Computed https://github.com/vapor/console-kit/ at 4.4.1 (0.58s)
Computing version for https://github.com/apple/swift-log.git
Computed https://github.com/apple/swift-log.git at 1.4.2 (0.48s)
Computing version for https://github.com/apple/swift-nio-ssl.git
Computed https://github.com/apple/swift-nio-ssl.git at 2.20.1 (0.59s)
Computing version for https://github.com/apple/swift-nio.git
Computed https://github.com/apple/swift-nio.git at 2.40.0 (0.84s)
Computing version for https://github.com/vapor/multipart-kit.git
Computed https://github.com/vapor/multipart-kit.git at 4.5.2 (0.50s)
Computing version for https://github.com/apple/swift-algorithms.git
Computed https://github.com/apple/swift-algorithms.git at 1.0.0 (0.49s)
Computing version for https://github.com/apple/swift-metrics.git
Computed https://github.com/apple/swift-metrics.git at 2.3.1 (0.49s)
Computing version for https://github.com/apple/swift-nio-extras.git
Computed https://github.com/apple/swift-nio-extras.git at 1.12.1 (0.62s)
Computing version for https://github.com/apple/swift-nio-http2.git
Computed https://github.com/apple/swift-nio-http2.git at 1.22.0 (0.58s)
Computing version for https://github.com/swift-server/swift-backtrace.git
Computed https://github.com/swift-server/swift-backtrace.git at 1.3.3 (0.50s)
Computing version for https://github.com/vapor/routing-kit.git
Computed https://github.com/vapor/routing-kit.git at 4.6.0 (0.50s)
Computing version for https://github.com/apple/swift-crypto.git
Computed https://github.com/apple/swift-crypto.git at 2.1.0 (0.57s)
Computing version for https://github.com/vapor/async-kit.git
Computed https://github.com/vapor/async-kit.git at 1.13.0 (0.51s)
Computing version for https://github.com/swift-server/async-http-client.git
Computed https://github.com/swift-server/async-http-client.git at 1.11.1 (0.57s)
Computing version for https://github.com/vapor/jwt-kit.git
Computed https://github.com/vapor/jwt-kit.git at 4.6.1 (0.53s)
Computing version for https://github.com/vapor/sqlite-kit.git
Computed https://github.com/vapor/sqlite-kit.git at 4.1.0 (0.52s)
Computing version for https://github.com/vapor/fluent-kit.git
Computed https://github.com/vapor/fluent-kit.git at 1.33.0 (0.56s)
Computing version for https://github.com/apple/swift-collections.git
Computed https://github.com/apple/swift-collections.git at 1.0.2 (0.58s)
Computing version for https://github.com/apple/swift-numerics
Computed https://github.com/apple/swift-numerics at 1.0.2 (0.57s)
Computing version for https://github.com/apple/swift-nio-transport-services.git
Computed https://github.com/apple/swift-nio-transport-services.git at 1.13.0 (0.52s)
Computing version for https://github.com/vapor/sql-kit.git
Computed https://github.com/vapor/sql-kit.git at 3.18.0 (0.52s)
Computing version for https://github.com/vapor/sqlite-nio.git
Computed https://github.com/vapor/sqlite-nio.git at 1.1.0 (0.52s)
Working copy of https://github.com/latencyzero/SwiftMODBUS resolved at main

It would be nice if it just visited the one dependency (and any sub-dependencies).

Expected behavior

I would expect only the named packages to be checked and updated (along with any sub-dependencies).

Actual behavior

Seems like it ignores the specified package names.

Steps to reproduce

In a Swift project with multiple dependencies, try updating a single one.

Swift Package Manager version/commit hash

5.6.2

Swift & OS version (output of swift --version && uname -a)

$ swift --version && uname -a Swift version 5.6.2 (swift-5.6.2-RELEASE) Target: aarch64-unknown-linux-gnu Linux furnace 5.10.103-v8+ #1530 SMP PREEMPT Tue Mar 8 13:06:35 GMT 2022 aarch64 GNU/Linux

Note that this is also the case on macOS.

keniwhat commented 1 year ago

This feature is essential for projects with many internal dependencies, which should take the latest available version, but ignore public repository dependencies. Is this a bug or a missing feature?

tomerd commented 1 year ago

cc @neonichu

neonichu commented 1 year ago

Could one of you clarify if the other dependencies are also updated to newer versions/commits or if we're just visiting them and updating the cached repos coincidentally? I believe the later is expected behavior and --skip-update might be the way to get the desired behavior.

JetForMe commented 1 year ago

I don't have time to try to set that up right now, and I'm not even sure how I would. You'd have to specify an "up to" style dependency, get one version of at least two repos, then publish new versions of each, and then run the update on a single dependency, and see if it updates both.

But I really don't want it to even visit the others and update caches, because it takes so much time. Just do the minimal amount of work to update the one I ask for. In fact, you might not even want to update sub-dependencies that don't need to be updated, but the option to have it do so might be useful. Then again, if you're updating to a new version of a dependency, it should have its own declaration of sub-dependencies suitably changed if it needs it.