Skip to content

Conversation

@itzlambda
Copy link
Collaborator

@itzlambda itzlambda commented Dec 15, 2025

Fixes the rerun-if-changed directive to use the path returned by dotenvy instead of checking a hardcoded location. This ensures the rebuild trigger correctly tracks the .env file that was actually loaded (which may be in a parent directory).

Summary by CodeRabbit

  • Chores
    • Enhanced the build system to intelligently search for environment configuration files within project directories and their parents, ensuring proper handling and management of build cache invalidation. This results in more reliable and consistent builds for all users compiling from source, with better support for various project structures and development environments.

✏️ Tip: You can customize this high-level summary in your review settings.

Use dotenvy's returned path for the rerun-if-changed directive instead of
checking a hardcoded location. This ensures the rebuild trigger correctly
tracks the .env file that was actually loaded (which may be in a parent
directory).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

The build script now searches for .env files in the current directory and parent directories, emitting cargo rerun directives only for the actual discovered path. The dotenv loading is made conditional on success, replacing unconditional rerun triggers for a hardcoded ".env" filename.

Changes

Cohort / File(s) Summary
Build script .env handling
crates/basilica-common/build.rs
Modified .env file discovery logic to search parent directories iteratively, emit rerun-if-changed only for the actual discovered path, and conditionally invoke dotenv() on success instead of unconditionally.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Review the directory traversal logic for correctness and edge cases (e.g., root directory termination)
  • Verify that the conditional dotenv() invocation properly handles missing files
  • Ensure the cargo rerun directive targets the correct absolute path

Possibly related PRs

Poem

🐰 A hop through parent dirs with care,
The .env file discovered somewhere,
No false reruns, no needless strife,
Just conditional loads—a cleaner build life!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the build script to use the actual .env file path for the rebuild trigger instead of a hardcoded one.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-env-loading

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e485d5d and d8a9f77.

📒 Files selected for processing (1)
  • crates/basilica-common/build.rs (1 hunks)
🔇 Additional comments (1)
crates/basilica-common/build.rs (1)

18-22: Good improvement—tracks the actual .env path.

The conditional loading and path-based rerun directive correctly implement the PR objective. The dotenvy::dotenv() API returns Result<PathBuf> as the code assumes, and the if let Ok(path) pattern properly handles both success and missing .env cases. The logic correctly handles the case where no .env file is found (defaults will be used per line 40), and tracking the actual discovered path (which may be in a parent directory) is more accurate than the previous hardcoded approach.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@itzlambda itzlambda marked this pull request as ready for review December 15, 2025 06:01
@itzlambda itzlambda merged commit c263b0c into main Dec 15, 2025
31 of 33 checks passed
@itzlambda itzlambda deleted the fix-env-loading branch December 15, 2025 06:13
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.

2 participants