Skip to content

fix(env): Enhance support for Git worktrees and shared virtual environments#108406

Open
armenzg wants to merge 1 commit intomasterfrom
git_worktrees/armenzg
Open

fix(env): Enhance support for Git worktrees and shared virtual environments#108406
armenzg wants to merge 1 commit intomasterfrom
git_worktrees/armenzg

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Feb 17, 2026

Updated .envrc to allow for a shared virtual environment across multiple Git worktrees by setting VIRTUAL_ENV dynamically. Node checks are now conditional based on the presence of a .node-version file, improving compatibility with different directory structures. Added documentation in AGENTS.md to clarify development practices with Git worktrees.

…nments

Updated .envrc to allow for a shared virtual environment across multiple Git worktrees by setting VIRTUAL_ENV dynamically. Node checks are now conditional based on the presence of a .node-version file, improving compatibility with different directory structures. Added documentation in AGENTS.md to clarify development practices with Git worktrees.
@armenzg armenzg self-assigned this Feb 17, 2026
@armenzg armenzg marked this pull request as ready for review February 17, 2026 23:01
@armenzg armenzg requested review from a team as code owners February 17, 2026 23:01
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

# not needed for getsentry
if [ "${PWD##*/}" = "sentry" ]; then
# only run Node checks when .node-version exists (sentry has it, getsentry does not); works for worktrees
if [ -f "${SENTRY_ROOT}/.node-version" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent path references for .node-version file

Low Severity

The guard on the new line checks ${SENTRY_ROOT}/.node-version for existence, but the read inside the block still uses bare .node-version (relative to PWD). Since SENTRY_ROOT resolves symlinks via pwd -P and PWD may not, these can refer to different filesystem paths. Before this change, both the guard and the read were implicitly PWD-relative, so they were consistent. The read (and the node_modules directory check) need to use "${SENTRY_ROOT}/.node-version" to match the guard, especially given the PR's goal of robust worktree and directory-structure support.

Additional Locations (1)

Fix in Cursor Fix in Web

if [ -f .venv/bin/devenv ]; then
DEVENV=.venv/bin/devenv
# VIRTUAL_ENV can be set in .env (e.g. to a primary worktree's .venv for Cursor Parallel Agents)
export VIRTUAL_ENV="${VIRTUAL_ENV:-$PWD/.venv}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Inherited VIRTUAL_ENV from parent shell silently misroutes environment

Low Severity

The ${VIRTUAL_ENV:-$PWD/.venv} pattern preserves any pre-existing VIRTUAL_ENV from the parent shell, not just values deliberately set in .env. If a developer has another virtualenv active (e.g. via source activate), the sentry .envrc will silently use that foreign virtualenv for the devenv lookup, PATH_add, and the exported VIRTUAL_ENV. The old code unconditionally set VIRTUAL_ENV to $PWD/.venv, so it was immune to this. A narrower mechanism that only respects the .env override would avoid this side effect.

Fix in Cursor Fix in Web

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.

1 participant