d
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
When running `bootstrap.py` on another machine, the installation completes successfully with messages about creating `mm.bat`, but the `mm` command is not recognized when executed.
|
When running `bootstrap.py` on another machine, the installation completes successfully with messages about creating `mm.bat`, but the `mm` command is not recognized when executed.
|
||||||
|
|
||||||
**Root Cause:** Windows terminal sessions cache the PATH environment variable. When registry changes are made, existing terminal sessions don't automatically reload the new PATH. The batch shim is created correctly, but it isn't discoverable until either the current session reloads PATH or a new terminal is opened.
|
**Root Cause:** Windows terminal sessions cache the PATH environment variable. When registry changes are made, existing terminal sessions don't automatically reload the new PATH. The PowerShell shim is created correctly, but it isn't discoverable until either the current session reloads PATH or a new terminal is opened.
|
||||||
|
|
||||||
## Solution
|
## Solution
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ python scripts/bootstrap.py --check-install
|
|||||||
```
|
```
|
||||||
|
|
||||||
This will check:
|
This will check:
|
||||||
- ✓ Batch shim exists (`mm.bat`)
|
- ✓ PowerShell shim exists (`mm.ps1`)
|
||||||
- ✓ Shim content is valid and points at the local venv
|
- ✓ Shim content is valid and points at the local venv
|
||||||
- ✓ PATH environment variable is configured
|
- ✓ PATH environment variable is configured
|
||||||
- ✓ Registry PATH was updated
|
- ✓ Registry PATH was updated
|
||||||
@@ -48,7 +48,7 @@ This will check:
|
|||||||
Checking 'mm' command installation...
|
Checking 'mm' command installation...
|
||||||
|
|
||||||
Checking for shim files:
|
Checking for shim files:
|
||||||
mm.bat: ✓ (C:\Users\Admin\bin\mm.bat)
|
mm.ps1: ✓ (C:\Users\Admin\bin\mm.ps1)
|
||||||
|
|
||||||
Checking PATH environment variable:
|
Checking PATH environment variable:
|
||||||
C:\Users\Admin\bin in current session PATH: ✗
|
C:\Users\Admin\bin in current session PATH: ✗
|
||||||
|
|||||||
@@ -551,18 +551,18 @@ def main() -> int:
|
|||||||
|
|
||||||
if system == "windows":
|
if system == "windows":
|
||||||
user_bin = Path(os.environ.get("USERPROFILE", str(home))) / "bin"
|
user_bin = Path(os.environ.get("USERPROFILE", str(home))) / "bin"
|
||||||
mm_bat = user_bin / "mm.bat"
|
mm_ps1 = user_bin / "mm.ps1"
|
||||||
|
|
||||||
print(f"Checking for shim files:")
|
print(f"Checking for shim files:")
|
||||||
print(f" mm.bat: {'✓' if mm_bat.exists() else '✗'} ({mm_bat})")
|
print(f" mm.ps1: {'✓' if mm_ps1.exists() else '✗'} ({mm_ps1})")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if mm_bat.exists():
|
if mm_ps1.exists():
|
||||||
bat_content = mm_bat.read_text(encoding="utf-8")
|
ps1_content = mm_ps1.read_text(encoding="utf-8")
|
||||||
if "REPO=" in bat_content or "PY=" in bat_content:
|
if "$repo =" in ps1_content or "$py =" in ps1_content:
|
||||||
print(f" mm.bat content looks valid ({len(bat_content)} bytes)")
|
print(f" mm.ps1 content looks valid ({len(ps1_content)} bytes)")
|
||||||
else:
|
else:
|
||||||
print(f" ⚠️ mm.bat content may be corrupted")
|
print(f" ⚠️ mm.ps1 content may be corrupted")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Check PATH
|
# Check PATH
|
||||||
@@ -992,42 +992,35 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
|||||||
if not (repo / "scripts").exists():
|
if not (repo / "scripts").exists():
|
||||||
print(f"WARNING: scripts folder not found at {repo}/scripts - mm command may not work", file=sys.stderr)
|
print(f"WARNING: scripts folder not found at {repo}/scripts - mm command may not work", file=sys.stderr)
|
||||||
|
|
||||||
# Write mm.bat (CMD shim for all shells; avoids PowerShell execution policy issues)
|
# Write mm.ps1 (PowerShell shim for global command)
|
||||||
mm_bat = user_bin / "mm.bat"
|
mm_ps1 = user_bin / "mm.ps1"
|
||||||
repo_bat_str = str(repo)
|
repo_ps1_str = str(repo).replace("\\", "\\\\")
|
||||||
bat_text = (
|
ps1_text = (
|
||||||
"@echo off\n"
|
"$repo = '{repo}'\n"
|
||||||
"setlocal enabledelayedexpansion\n"
|
"$venv = Join-Path $repo '.venv'\n"
|
||||||
f'set "REPO={repo_bat_str}"\n'
|
"$py = Join-Path $venv 'Scripts' 'python.exe'\n"
|
||||||
"set \"VENV=!REPO!\\.venv\"\n"
|
"$entry = Join-Path $repo 'scripts' 'cli_entry.py'\n"
|
||||||
"set \"PY=!VENV!\\Scripts\\python.exe\"\n"
|
"if (Test-Path $py) {{\n"
|
||||||
"set \"ENTRY=!REPO!\\scripts\\cli_entry.py\"\n"
|
" & $py $entry $args\n"
|
||||||
"if exist \"!PY!\" (\n"
|
" exit $LASTEXITCODE\n"
|
||||||
" if defined MM_DEBUG (\n"
|
"}}\n"
|
||||||
" echo MM_DEBUG: using venv python at !PY!\n"
|
"Write-Host 'MM: venv python not found at '$py\n"
|
||||||
" \"!PY!\" -c \"import sys; print('sys.executable:', sys.executable); print('sys.path:', sys.path[:5])\"\n"
|
"python $entry $args\n"
|
||||||
" )\n"
|
"exit $LASTEXITCODE\n"
|
||||||
" \"!PY!\" \"!ENTRY!\" %*\n"
|
).format(repo=repo_ps1_str)
|
||||||
" exit /b !ERRORLEVEL!\n"
|
if mm_ps1.exists():
|
||||||
")\n"
|
bak = mm_ps1.with_suffix(f".bak{int(time.time())}")
|
||||||
"echo MM: venv python not found at !PY!\n"
|
mm_ps1.replace(bak)
|
||||||
"if defined MM_DEBUG echo MM_DEBUG: venv python not found, trying system python\n"
|
mm_ps1.write_text(ps1_text, encoding="utf-8")
|
||||||
"python \"!ENTRY!\" %*\n"
|
|
||||||
"exit /b !ERRORLEVEL!\n"
|
|
||||||
)
|
|
||||||
if mm_bat.exists():
|
|
||||||
bak = mm_bat.with_suffix(f".bak{int(time.time())}")
|
|
||||||
mm_bat.replace(bak)
|
|
||||||
mm_bat.write_text(bat_text, encoding="utf-8")
|
|
||||||
|
|
||||||
# Validate that the batch shim was created correctly
|
# Validate that the PowerShell shim was created correctly
|
||||||
bat_ok = mm_bat.exists() and len(mm_bat.read_text(encoding="utf-8")) > 0
|
ps1_ok = mm_ps1.exists() and len(mm_ps1.read_text(encoding="utf-8")) > 0
|
||||||
if not bat_ok:
|
if not ps1_ok:
|
||||||
raise RuntimeError("Failed to create mm.bat shim")
|
raise RuntimeError("Failed to create mm.ps1 shim")
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
print(f"DEBUG: Created mm.bat ({len(bat_text)} bytes)")
|
print(f"DEBUG: Created mm.ps1 ({len(ps1_text)} bytes)")
|
||||||
print(f"DEBUG: Repo path embedded in shims: {repo}")
|
print(f"DEBUG: Repo path embedded in shim: {repo}")
|
||||||
print(f"DEBUG: Venv location: {repo}/.venv")
|
print(f"DEBUG: Venv location: {repo}/.venv")
|
||||||
print(f"DEBUG: Shim directory: {user_bin}")
|
print(f"DEBUG: Shim directory: {user_bin}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user