Skip to content

Refactor bundler settings to use config rs#642

Merged
deivid-rodriguez merged 4 commits intospinel-coop:mainfrom
a-chacon:refactor-bundler-settings-to-use-config-rs
Apr 7, 2026
Merged

Refactor bundler settings to use config rs#642
deivid-rodriguez merged 4 commits intospinel-coop:mainfrom
a-chacon:refactor-bundler-settings-to-use-config-rs

Conversation

@a-chacon
Copy link
Copy Markdown
Contributor

@deivid-rodriguez give me this idea of refactor bundler settings to use config-rs just like rv-settings is doing. I think the code is clearer now.

I just have one question about the precedence, now it is clear:

  • Global
  • Local
  • Environment variables

But before were a logic that confuse me about use_deployment and InstallPath struct. I am not so sure about accomplishing exactly the same logic. But I take care about all specs were working just like before.

@indirect
Copy link
Copy Markdown
Member

I believe the ENV should always override local, and local should always override global. I will wait to hear from @deivid-rodriguez to know if I am right, though. 😅

@a-chacon
Copy link
Copy Markdown
Contributor Author

You are right, but yes, let's wait for a review of david!

@deivid-rodriguez
Copy link
Copy Markdown
Collaborator

deivid-rodriguez commented Mar 30, 2026

@a-chacon It's a good question. In my opinion, the precedence that makes the most sense is indeed ENV > local > global, but Bundler weirdly uses local > ENV > global, so that's why the existing logic had that precedence, because I respected it since this layer is about Bundler compatibility.

To try to clarify how deployment works with the other settings, the default path where Bundler installs gem is, by order of priority:

  1. What's configured as path locally in ./.bundle/config.
  2. What's set by BUNDLE_PATH if path not configured locally in ./.bundle/config.
  3. What's configured as path globally in ~/.bundle/config if not configured locally nor in ENV.
  4. vendor/bundle if deployment configured at any level and path not configured at any level.
  5. Otherwise, the default path.

@deivid-rodriguez
Copy link
Copy Markdown
Collaborator

Other comment where I think this differs from my initial implementation is that I intentionally tried to make this "best effort" only and never fail if we can't read Bundler settings for whatever reason, just ignore them. We should definitely be debug-logging any failures, but I'm not 100% sure if we should fail if errors happen, since after all, it's not really required for rv to work.

@a-chacon a-chacon force-pushed the refactor-bundler-settings-to-use-config-rs branch from d810d8d to e0c00ac Compare March 31, 2026 22:48
@a-chacon
Copy link
Copy Markdown
Contributor Author

@deivid-rodriguez I get it. I think this accomplishes the logic now. With default do you means return None at the path() function yes?.

You didn't mention the BUNDLE_PATH__SYSTEM in the flow. But based on the old code this just return none if it is present and true. This is respected too.

Also, I added a log and load default if something fails inside the bundler settings. Well let me know any comment on it.

@deivid-rodriguez
Copy link
Copy Markdown
Collaborator

deivid-rodriguez commented Apr 1, 2026

@deivid-rodriguez I get it. I think this accomplishes the logic now. With default do you means return None at the path() function yes?.

Yes, because that means we end up setting GEM_HOME to the default path 👍

You didn't mention the BUNDLE_PATH__SYSTEM in the flow. But based on the old code this just return none if it is present and true. This is respected too.

True, I forgot that one. That's essentially an special value for BUNDLE_PATH that means "install to the default GEM_HOME". So yeah, you got that one right. If true, it means return None so the code I linked to above fallbacks to the default GEM_HOME 👍

Also, I added a log and load default if something fails inside the bundler settings. Well let me know any comment on it.

Cool, I'll review this later today, thank you so much!

Copy link
Copy Markdown
Collaborator

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Looking great, just a small comment. I did notice #646 while reviewing, but not related to this PR. Needs a rebase though!

Comment thread crates/rv/src/config/bundler_settings.rs Outdated
Comment thread crates/rv/src/config/bundler_settings.rs Outdated
Comment thread crates/rv/src/config/bundler_settings.rs Outdated
@a-chacon a-chacon force-pushed the refactor-bundler-settings-to-use-config-rs branch 2 times, most recently from 53bd2f8 to 2c6e292 Compare April 1, 2026 19:55
@deivid-rodriguez deivid-rodriguez force-pushed the refactor-bundler-settings-to-use-config-rs branch from 2c6e292 to 0e5c4b5 Compare April 7, 2026 08:12
Copy link
Copy Markdown
Collaborator

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Thank you @a-chacon! Just did some trivial squashing of dummy review commits and I'm now merging this 💪

@deivid-rodriguez deivid-rodriguez added this pull request to the merge queue Apr 7, 2026
Merged via the queue into spinel-coop:main with commit eec4f99 Apr 7, 2026
27 checks passed
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.

3 participants