Skip to content

Conversation

@fruno-bulax
Copy link
Contributor

@fruno-bulax fruno-bulax commented Nov 19, 2025

Fixes #5132
Fixes #5084

When changing the type of source (like from hex to local), the manifest entry was not updated.
This causes gleam to hit hex for version resolution on each operation, quickly running into API limits.

Additionally, the manifest was not updated if there were only changes in requirements but not packages. This could happen if when changing version constraints or adding/removing a direct dependency to a package that is also a transitive dependency.
For this I split the Resolved struct up, as some usages only cared about the package changes.

Comment on lines 602 to 642
#[test]
fn resolved_with_updated() {
#[cfg(test)]
mod manifest_update_tests {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this diff is very confusing: I just moved the existing test into a module and added the resolved_with_source_type_change test below it.

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thank you!! I was hoping to find time to do this this week. You're too fast for me!

One tiny note inline

for new in &new.packages {
match old.remove(&new.name) {
// If the kind of source changed, the packages bear essentially no connection
Some(old) if discriminant(&old.source) != discriminant(&new.source) => {
Copy link
Member

@lpil lpil Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is magical and can also result in unexpected behaviour if misused. Please use a normal function with a match expression instead 🙏

pub fn kind(&self) -> ManifestPackageSourceKind {
  match &self {
    Self::Hex { .. } => ManifestPackageSource::Hex
    // ...

Copy link
Contributor Author

@fruno-bulax fruno-bulax Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to be too clever is a habit I'm working to get rid of 😅
Done!

@fruno-bulax fruno-bulax force-pushed the change-pkg-source branch 2 times, most recently from e13cd54 to f330256 Compare November 20, 2025 20:10
@fruno-bulax fruno-bulax marked this pull request as draft November 21, 2025 15:19
@fruno-bulax
Copy link
Contributor Author

Converting this to a draft until I've addressed a related but different issue: #5132 (comment)

@fruno-bulax fruno-bulax force-pushed the change-pkg-source branch 3 times, most recently from 4cb7490 to ca7dfd6 Compare November 22, 2025 10:07
@fruno-bulax fruno-bulax marked this pull request as ready for review November 22, 2025 11:01
@fruno-bulax fruno-bulax requested a review from lpil November 22, 2025 11:01
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Thank you!!!

@lpil lpil merged commit 9f53336 into gleam-lang:main Nov 22, 2025
11 of 12 checks passed
@fruno-bulax fruno-bulax deleted the change-pkg-source branch November 22, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excessive Hex API calls during normal development hitting rate limits gleam build sometimes incorrectly verifies dependencies and hits Hex.

2 participants