Skip to content

Fix: Allow shell builtins to work with pipenv run#6487

Merged
matteius merged 1 commit intomainfrom
fix/shell-builtins-6186
Dec 10, 2025
Merged

Fix: Allow shell builtins to work with pipenv run#6487
matteius merged 1 commit intomainfrom
fix/shell-builtins-6186

Conversation

@matteius
Copy link
Copy Markdown
Member

Summary

Shell builtins (cd, echo, pwd, export, etc.) don't exist as files in the PATH - they're built into the shell itself. Previously, pipenv run cd would fail with:

Error: the command cd could not be found within PATH or Pipfile's [scripts].

Changes

Modifies do_run_posix in pipenv/routines/shell.py to fall back to running commands through the shell when they're not found in PATH, similar to the Windows behavior that already existed in _launch_windows_subprocess.

Before (POSIX)

  1. Try to find command in PATH using system_which
  2. If not found → error and exit

After (POSIX)

  1. Try to find command in PATH using system_which
  2. If found → use os.execve for direct execution (unchanged)
  3. If not found → fall back to subprocess.run with shell=True (allows shell builtins to work)

Testing

  • Added integration test test_run_shell_builtins that tests echo, pwd, and cd builtins
  • Manual testing confirms that pipenv run echo, pipenv run pwd, and pipenv run cd now work correctly

Fixes #6186


Pull Request opened by Augment Code with guidance from the PR author

Shell builtins (cd, echo, pwd, export, etc.) don't exist as files in the
PATH - they're built into the shell itself. Previously, `pipenv run cd`
would fail with 'command could not be found' error.

The fix modifies do_run_posix to fall back to running commands through
the shell when they're not found in PATH, similar to the Windows behavior
that already existed in _launch_windows_subprocess.

Fixes #6186
@matteius matteius merged commit e58b717 into main Dec 10, 2025
2 checks passed
@matteius matteius deleted the fix/shell-builtins-6186 branch December 10, 2025 21:21
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.

Can Not Use Shell Builtin as First Command in pipenv run

1 participant