-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the pi-log wiki!
(macOS → VS Code → pyenv → pre-commit)
This document summarizes the investigation and resolution of issues involving VS Code launching the wrong shell, pyenv not initializing, and pre-commit failing to locate Python 3.10 for the ansible-lint hook.
- VS Code terminals were launching
bashinstead ofzsh. - pyenv initialization was not occurring inside VS Code.
-
python3.10was not discoverable in VS Code, even though it worked in Terminal.app. - pre-commit failed to build the ansible-lint hook environment due to missing Python 3.10.
- VS Code was ignoring the user-level setting:
"terminal.integrated.defaultProfile.osx": "zsh" - VS Code continued launching
/bin/bashdue to cached profile state.
- Because VS Code was launching bash,
.zshrcwas never sourced. - pyenv shims were not added to
$PATH.
- pre-commit attempted to create a Python 3.10 environment for ansible-lint.
- VS Code’s bash shell could not locate
python3.10, causing hook installation failure.
Checked the system shell:
dscl . -read /Users/$USER UserShell
Output:
UserShell: /bin/zsh
- Used
Terminal: Select Default Profileto explicitly selectzsh. - Cleared VS Code’s cached terminal state.
- Fully restarted VS Code.
Added:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Confirmed:
which python3.10
Output:
/Users/jebbaugh/.pyenv/shims/python3.10
The previous configuration attempted to install:
-
ansible-lint==23.12.2(manual pin) -
ansible-lint 0.1.dev1(from the hook repo)
This caused pip dependency resolution failure.
Replaced the hook with:
default_language_version:
python: python3.10
repos:
- repo: https://github.com/ansible/ansible-lint
rev: v24.2.0
hooks:
- id: ansible-lint
name: ansible-lint (pi-log)
files: ^ansible/
pre-commit clean
pre-commit install
pre-commit run --all-files
Result: all hooks passed successfully.
- VS Code now launches
zshconsistently. - pyenv initializes correctly inside VS Code.
-
python3.10is available to pre-commit. - ansible-lint installs without version conflicts.
- The development environment is stable and reproducible.
- User-level settings do not always control the terminal profile.
- VS Code may cache the previous shell and ignore updated settings.
- Workspace settings can silently override user settings.
- pyenv only initializes when the correct shell startup file is sourced.
- If VS Code launches bash,
.zshrcis never evaluated. - Interpreter discovery failures in pre-commit often trace back to pyenv not loading.
- pre-commit hook environments use their own Python interpreter.
- The project’s
.venvPython version does not influence hook creation. - Python 3.10 must be discoverable globally for ansible-lint hooks.
- The ansible-lint hook repository already defines its own package version.
- Adding a second version via
additional_dependenciescreates unavoidable conflicts. - The correct way to pin ansible-lint is through the
rev:field only.
- macOS login shell
- VS Code terminal profile
- pyenv initialization
- pre-commit interpreter selection
- project virtual environment
Any mismatch in this chain produces cascading failures.
- pre-commit failed to install ansible-lint due to missing Python 3.10.
- VS Code terminal reported
/bin/bashinstead of/bin/zsh. - pyenv was not initializing inside VS Code.
- Verified macOS login shell was correctly set to zsh.
- Identified VS Code was ignoring user settings.
- Confirmed no workspace-level overrides existed.
- Determined VS Code was using a cached terminal profile.
- Forced VS Code to select zsh via profile selector.
- Cleared VS Code terminal state.
- Restarted VS Code and confirmed
echo $SHELLreturned/bin/zsh.
- Added pyenv initialization to
.zshrc. - Verified
which python3.10returned pyenv shim path. - Confirmed VS Code inherited the correct environment.
- Identified conflicting ansible-lint versions (
0.1.dev1vs23.12.2). - Removed
additional_dependenciesfrom the hook config. - Updated
.pre-commit-config.yamlto rely solely onrev:. - Rebuilt hook environments successfully.
- pre-commit ran cleanly.
- ansible-lint installed without conflict.
- Development environment stabilized.
- Run
echo $SHELLinside VS Code. - Confirm output is
/bin/zsh. - If not, use
Terminal: Select Default Profileto choose zsh. - Clear VS Code terminal state if profile changes do not apply.
- Run
dscl . -read /Users/$USER UserShell. - Confirm output is
/bin/zsh. - If not, run
chsh -s /bin/zshand log out/in.
- Ensure
.zshrccontains:export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" - Run
which python3.10inside VS Code. - Confirm the path points to pyenv shims.
- Confirm
.pre-commit-config.yamlsets:default_language_version: python: python3.10 - Ensure no Python version pins conflict with pyenv.
- Remove all
additional_dependenciesfrom the ansible-lint hook. - Pin the version only via
rev::rev: v24.2.0 - Rebuild environments:
pre-commit clean pre-commit install
- Run
pre-commit run --all-files. - Confirm all hooks pass.
- Confirm VS Code and Terminal.app behave identically. # Appendix D — Shell/Environment Flowchart (Mermaid + ASCII)
flowchart TD
A[VS Code launches terminal] --> B{Which shell starts?}
B -->|/bin/zsh| C[pyenv initializes]
B -->|/bin/bash| D[pyenv does NOT initialize]
C --> E{python3.10 available?}
D --> E
E -->|Yes| F[pre-commit can build ansible-lint env]
E -->|No| G[pre-commit fails to find interpreter]
G --> H{ansible-lint pinned twice?}
H -->|Yes| I[Dependency conflict: 0.1.dev1 vs pinned version]
H -->|No| J[Interpreter discovery failure]
I --> K[Fix: remove additional_dependencies]
J --> L[Fix: ensure VS Code uses zsh + pyenv loads]
K --> M[Rebuild pre-commit envs]
L --> M
M --> N[System stable]
+---------------------------+
| VS Code launches terminal |
+-------------+-------------+
|
v
+-------+--------+
| Which shell? |
+-------+--------+
|
+----------+-----------+
| |
v v
/bin/zsh /bin/bash
(pyenv loads) (pyenv does NOT load)
| |
+----------+-----------+
|
v
+----------+-----------+
| python3.10 available?|
+----------+-----------+
|
+----------+-----------+
| |
v v
Yes No
(pre-commit OK) (pre-commit fails)
|
v
+-----------+-----------+
| ansible-lint pinned? |
+-----------+-----------+
|
+-----------+-----------+
| |
v v
Yes (conflict) No (missing pyenv)
Remove additional_deps Fix VS Code shell
|
v
Rebuild pre-commit envs
|
v
System stable
The failure originated from VS Code launching the wrong shell (bash), preventing pyenv initialization and causing pre-commit to fail when building the ansible-lint hook environment. A secondary issue involved conflicting ansible-lint versions due to manual pinning.
pre-commit could not install ansible-lint because Python 3.10 was not discoverable inside VS Code, and pip encountered conflicting ansible-lint versions.
- pre-commit hooks could not run
- ansible-lint environment failed to build
- inconsistent behavior between VS Code and Terminal.app
- development workflow blocked
- Cached terminal profile ignored user settings.
-
.zshrcwas never sourced.
- pyenv shims were not added to
$PATH. -
python3.10was not discoverable.
- Hook repo defined
ansible-lint==0.1.dev1. -
.pre-commit-config.yamlpinnedansible-lint==23.12.2. - pip refused to install both.
- VS Code terminal profile caching
- Lack of pyenv initialization in bash
- Misuse of
additional_dependenciesin pre-commit
- Forced VS Code to use zsh via profile selector.
- Cleared VS Code terminal state.
- Ensured pyenv initialization in
.zshrc. - Removed ansible-lint version pinning from
additional_dependencies. - Rebuilt pre-commit environments.
- Avoid pinning ansible-lint via
additional_dependencies. - Verify VS Code shell after updates.
- Keep pyenv initialization in
.zshrconly. - Use
rev:to pin hook versions.
This section provides guidance for future maintainers working on pi-log to ensure consistent shell behavior, interpreter discovery, and pre-commit reliability.
- macOS (development)
- pyenv
- Python 3.9 (project runtime)
- Python 3.10 (pre-commit hooks)
- VS Code
- VS Code must launch
zsh, notbash. - pyenv must initialize automatically.
-
python3.10must be discoverable globally. -
.venvuses Python 3.9 for runtime. - pre-commit uses Python 3.10 for ansible-lint.
- Install pyenv and Python versions:
pyenv install 3.9.6 pyenv install 3.10.x - Ensure
.zshrccontains:export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" - Verify VS Code shell:
- Command Palette → Terminal: Select Default Profile → zsh
- Create project virtual environment:
python3.9 -m venv .venv - Install dependencies:
pip install -r requirements.txt - Install pre-commit:
pre-commit install
-
which python3.10returns a pyenv shim. -
pre-commit run --all-filespasses. - VS Code and Terminal.app behave identically.
Symptoms:
-
echo $SHELL→/bin/bash - pyenv not loading
Actions:
- Command Palette → Terminal: Select Default Profile → zsh
- Quit VS Code completely
- Remove terminal state:
rm -rf ~/Library/Application\ Support/Code/User/globalStorage/state.vscdb*
Symptoms:
-
which python3.10returns nothing - pre-commit cannot find Python 3.10
Actions:
Add to .zshrc:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Reload:
source ~/.zshrc
Symptoms:
- pip conflict errors
- mentions
ansible-lint 0.1.dev1vsansible-lint==X.Y.Z
Actions:
- Remove all
additional_dependenciesfrom ansible-lint hook - Pin only via
rev: - Rebuild:
pre-commit clean pre-commit install
Symptoms:
-
.venvuses wrong Python version - ansible-lint uses wrong interpreter
Actions:
- Recreate venv with Python 3.9:
python3.9 -m venv .venv - Ensure pre-commit uses Python 3.10:
default_language_version: python: python3.10
Symptoms:
- Commands work in Terminal.app but not VS Code
Actions:
- Confirm VS Code is launching zsh
- Confirm
.zshrcloads pyenv - Compare:
env | sort
-
echo $SHELL→/bin/zsh -
which python3.10→ pyenv shim -
.venvuses Python 3.9 - pre-commit installs cleanly
- ansible-lint runs without conflict
- VS Code and Terminal.app match