Repository navigation
perf(generate): skip nix check and telemetry for direnv --print-envrc - #3022
Merged
Merged
Conversation
direnv runs `devbox generate direnv --print-envrc` on every reload. It only prints a fixed .envrc template, but it inherited the nix install check from `generate` (which runs `nix --version`) and recorded a telemetry event, which also spawned the telemetry uploader. Skip the nix check in generate's PersistentPreRunE when --print-envrc is set, and add midcobra.SkipTelemetry so the command can opt out of being recorded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
@claude ptal |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
PR #3022 was updated after the trigger (2026-10-25T21:46:37Z >= 2026-10-25T21:44:10Z). Mention Claude again to run on the latest version. |
Collaborator
Author
|
@claude ptal |
|
Claude finished @mikeland73's task in 17s —— View job Review of PR #3022Looks good to me. I found no blocking issues. I read the diff and the surrounding code but didn't run the tests or build the binary.
What I checked
Minor, non-blocking notes
Overall, this is ready to merge once CI is green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements item 5 of
specs/perf-improvements.md.direnv runs
devbox generate direnv --print-envrcon every reload. It only prints a fixed.envrctemplate, but it still:ensureNixInstalledfromgenerate'sPersistentPreRunE, which runsnix --version, anddevbox upload-telemetryprocess.Changes:
generate'sPersistentPreRunEskips the nix check when--print-envrcis set. The root usescobra.EnableTraverseRunHooks, so overriding the hook on thedirenvsubcommand wouldn't stop the parent's hook from running. That's why the check goes in the parent.midcobra.SkipTelemetry(cmd)lets a command opt out of being recorded for the current run. The telemetry post-run hook checks for it. The--print-envrcpath calls it.Testing
TestGenerateDirenvPrintEnvrcSkipsNixCheckruns the command throughRootCmd()and checks the output and thatnix.Ensured()stays false. Without the fix it fails.TestSkipTelemetry.go test ./internal/boxcli/...passes.golangci-lint run ./internal/boxcli/...reports 0 issues.main.generate direnv --print-envrcon macOS, averaged over 20 runs. Binaries were built with fake telemetry keys and network was blocked by a proxy.DO_NOT_TRACK=1With telemetry on, almost all of the remaining ~23ms is
telemetry.Start()runningioregfor the machine ID. #3021 caches that.🤖 Generated with Claude Code