Skip to content

Add support for .envrc.local#1120

Merged
marcoroth merged 1 commit intomarcoroth:mainfrom
citizen428:envrc-local
Feb 3, 2026
Merged

Add support for .envrc.local#1120
marcoroth merged 1 commit intomarcoroth:mainfrom
citizen428:envrc-local

Conversation

@citizen428
Copy link
Contributor

I think that when including an .envrc in a repository, it's a good practice to also conditionally source another .envrc file so users can customize their environment without having to worry about accidentally committing changes. I needed this today so figured I'll open a PR.

Copy link
Owner

@marcoroth marcoroth 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, @citizen428! 🙏🏼

export PATH="$PWD/java/bin:$PATH"
export PATH="$PWD/rust/bin:$PATH"

source_env_if_exists .envrc.local
Copy link
Owner

Choose a reason for hiding this comment

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

TIL source_env_if_exists

@marcoroth marcoroth merged commit 2dee5e7 into marcoroth:main Feb 3, 2026
12 checks passed
@citizen428 citizen428 deleted the envrc-local branch February 3, 2026 16:47
marcoroth pushed a commit that referenced this pull request Feb 5, 2026
This PR changes how `clang`, `clang-tidy`, etc., are detected on macOS
without requiring any changes for current users.

**Rationale:** 
Not everyone uses Homebrew in this way. I personally only use it for
application formulae and kegs, and manage my dev dependencies with Nix
flakes (which is also what motivated #1120).

**Proposed solution:** 
Use the Homebrew prefix by default on macOS, as it's a sensible choice.
Users who install `clang` and friends some other way can probably figure
out how to override the values as required for their environment (either
by exporting environment variables or directly in the `make`
invocation).

**Verification:** 
I temporarily added the following task to the `Makefile`:

```make
debug_cc:
	@echo "os:            $(os)"
	@echo "cc:            $(cc)"
	@echo "clang_format:  $(clang_format)"
	@echo "clang_tidy:    $(clang_tidy)"
	@echo "test_cflags:   $(test_cflags)"
	@echo "test_ldflags:  $(test_ldflags)"
```

I ran this before and after making the changes in this PR, the generated
output was identical for the Homebrew use case:

```sh
❯ diff -s cc.old.txt cc.new.txt
Files cc.old.txt and cc.new.txt are identical
```

**Notes:**
1. The `debug_cc` target could be generally useful, also for Linux
users. If you want, I can add it to either this PR or separately.
2. It's a sort of convention in `Makefile`s to call the variables `CC`,
`CFLAGS`, etc. This is primarily because they can be overridden from the
environment, and lower-case environment variables look a bit odd.
However, I decided not to change this in this PR, as it's not really
related to the problem I'm trying to solve here.
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