Skip to content

Instantly share code, notes, and snippets.

@aliemo
Created December 13, 2025 19:50
Show Gist options
  • Select an option

  • Save aliemo/6158afaf7c321160ae1ef717da2452b4 to your computer and use it in GitHub Desktop.

Select an option

Save aliemo/6158afaf7c321160ae1ef717da2452b4 to your computer and use it in GitHub Desktop.
WSL Issues for terminal citizens

WSL Issues for Terminal Citizens

Practical fixes for real-world Windows Subsystem for Linux (WSL) problems faced by developers who live in the terminal and expect Linux-correct behavior.

This guide focuses on:

  • Minimal and reversible changes
  • No hacks unless unavoidable
  • Predictable Linux semantics

Issue 1: Git commands are very slow on /mnt/*

Symptom

When a Git repository is located on the Windows filesystem:

/mnt/c/Users/.../project

Git commands such as:

  • git status
  • git diff
  • git add

are painfully slow.

Root Cause:

  • /mnt/* is backed by Windows NTFS
  • WSL must translate filesystem calls
  • Git performs many small stat() operations
  • Performance degradation is unavoidable

Move repositories into the WSL filesystem: /home/<user>/projects

This provides native Linux Git performance.

Alternative: Automatically use Windows git.exe on /mnt/[path/to/git/dir]

If repositories must remain on /mnt/c, use Windows Git automatically.

Add this function to ~/.bashrc or ~/.zshrc:

git() {
    if pwd | grep -q '^/mnt/'; then
        git.exe "$@"
    else
        command git "$@"
    fi
}

Advantages:

  • Fast Git operations on Windows paths
  • Native Linux Git elsewhere
  • Transparent behavior

Issue 2: sudo shows sud.dll

Root Cause

  • Windows PATH is exposed inside WSL
  • Shell completion scans all PATH entries
  • Windows DLLs appear in tab completion

Fix (Minimal and Safe)

bash

  1. Add to ~/.bashrc:
export FIGNORE='*.dll'
  1. Reload:
source ~/.bashrc

zsh

  1. Add to ~/.zshrc
zstyle ':completion:*' ignored-patterns '*.dll'
  1. Reload:
source ~/.zshrc

Result

  • No PATH changes
  • Windows tools remain usable
  • Only tab completion is affected

Feel free to leave your comments here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment