# Force installing oldest supported version of a dependency?

**URL:** <https://forums.swift.org/t/force-installing-oldest-supported-version-of-a-dependency/76389>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [December 5, 2024, 1:28am UTC](https://forums.swift.org/t/force-installing-oldest-supported-version-of-a-dependency/76389 "2024-12-05T01:28:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephduffy](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/josephduffy/32/10814_2.png) [@josephduffy](https://forums.swift.org/u/josephduffy)\
**Post date:** [December 5, 2024, 1:28am UTC](https://forums.swift.org/t/force-installing-oldest-supported-version-of-a-dependency/76389/1 "2024-12-05T01:28:43Z")

</div>

As I understand it the reason to use `from: "version"` is to enable better compatibility with other packages in the same dependency graph. A good example of this would be setting the minimum version of `swift-syntax` when providing a macro.

When developing locally and running tests in CI the `Package.resolved` file will be used, but this will usually have the latest version of the dependency (or something newer than the version in the `Package.swift` file).

Is there a (simple) way to have SwiftPM install the oldest supported version of a dependency so I can validate that the `from` value is correct? This would be useful locally but may be crucial in CI.

Removing the `Package.resolved` file and replacing `from: "version"` with `exact: "version"` is one way to do this, but it would be nice if there were a more automated/official way of doing this.

---

<div class="post-metadata">

**Author:** ![vanvoorden](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/vanvoorden/32/33619_2.png) [@vanvoorden](https://forums.swift.org/u/vanvoorden)\
**Post date:** [December 5, 2024, 1:44am UTC](https://forums.swift.org/t/force-installing-oldest-supported-version-of-a-dependency/76389/2 "2024-12-05T01:44:35Z")

</div>

I'm not sure if there is any kind of direct ability to manipulate a package in this way.

A legit workaround might be to define an environment variable from shell before you begin your build. Your package manifest could then add conditional logic off the state of that variable to pick an exact version of the dependency you are trying to test against.

---

<div class="post-metadata">

**Author:** ![josephduffy](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/josephduffy/32/10814_2.png) [@josephduffy](https://forums.swift.org/u/josephduffy)\
**Post date:** [December 6, 2024, 1:37am UTC](https://forums.swift.org/t/force-installing-oldest-supported-version-of-a-dependency/76389/3 "2024-12-06T01:37:16Z")

</div>

I may look in to this, but I am hoping there's a solution that doesn't require extra maintenance or complications of the `Package.swift` file.

I looked at the tools we currently have access to. I think this will be possibly by parsing the output of `swift package dump-package` and then running `swift package resolve` with the `lowerBound` of each dependency. At least this doesn't modify the `Package.swift` file and relies on `swift` itself to do the resolving and updating of `Package.resolved`.
