fd
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 PowerShell 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 batch 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:
|
||||||
- ✓ PowerShell shim exists (`mm.ps1`)
|
- ✓ Batch shim exists (`mm.bat`)
|
||||||
- ✓ 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.ps1: ✓ (C:\Users\Admin\bin\mm.ps1)
|
mm.bat: ✓ (C:\Users\Admin\bin\mm.bat)
|
||||||
|
|
||||||
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_ps1 = user_bin / "mm.ps1"
|
mm_bat = user_bin / "mm.bat"
|
||||||
|
|
||||||
print(f"Checking for shim files:")
|
print(f"Checking for shim files:")
|
||||||
print(f" mm.ps1: {'✓' if mm_ps1.exists() else '✗'} ({mm_ps1})")
|
print(f" mm.bat: {'✓' if mm_bat.exists() else '✗'} ({mm_bat})")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
if mm_ps1.exists():
|
if mm_bat.exists():
|
||||||
ps1_content = mm_ps1.read_text(encoding="utf-8")
|
bat_content = mm_bat.read_text(encoding="utf-8")
|
||||||
if "$repo =" in ps1_content or "$py =" in ps1_content:
|
if "REPO=" in bat_content or "ENTRY=" in bat_content:
|
||||||
print(f" mm.ps1 content looks valid ({len(ps1_content)} bytes)")
|
print(f" mm.bat content looks valid ({len(bat_content)} bytes)")
|
||||||
else:
|
else:
|
||||||
print(f" ⚠️ mm.ps1 content may be corrupted")
|
print(f" ⚠️ mm.bat content may be corrupted")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Check PATH
|
# Check PATH
|
||||||
@@ -992,34 +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.ps1 (PowerShell shim for global command)
|
# Write mm.bat (batch shim works in all shells, bypasses PowerShell execution policy)
|
||||||
mm_ps1 = user_bin / "mm.ps1"
|
mm_bat = user_bin / "mm.bat"
|
||||||
repo_ps1_str = str(repo).replace("\\", "\\\\")
|
repo_bat_str = str(repo)
|
||||||
ps1_text = (
|
bat_text = (
|
||||||
"$repo = '{repo}'\n"
|
"@echo off\n"
|
||||||
"$venv = Join-Path $repo '.venv'\n"
|
"setlocal enabledelayedexpansion\n"
|
||||||
"$py = Join-Path $venv 'Scripts' 'python.exe'\n"
|
f'set "REPO={repo_bat_str}"\n'
|
||||||
"$entry = Join-Path $repo 'scripts' 'cli_entry.py'\n"
|
"set \"VENV=!REPO!\\.venv\"\n"
|
||||||
"if (Test-Path $py) {{\n"
|
"set \"PY=!VENV!\\Scripts\\python.exe\"\n"
|
||||||
" & $py $entry $args\n"
|
"set \"ENTRY=!REPO!\\scripts\\cli_entry.py\"\n"
|
||||||
" exit $LASTEXITCODE\n"
|
"if exist \"!PY!\" (\n"
|
||||||
"}}\n"
|
" \"!PY!\" \"!ENTRY!\" %*\n"
|
||||||
"Write-Host 'MM: venv python not found at '$py\n"
|
" exit /b !ERRORLEVEL!\n"
|
||||||
"python $entry $args\n"
|
")\n"
|
||||||
"exit $LASTEXITCODE\n"
|
"python \"!ENTRY!\" %*\n"
|
||||||
).format(repo=repo_ps1_str)
|
"exit /b !ERRORLEVEL!\n"
|
||||||
if mm_ps1.exists():
|
)
|
||||||
bak = mm_ps1.with_suffix(f".bak{int(time.time())}")
|
if mm_bat.exists():
|
||||||
mm_ps1.replace(bak)
|
bak = mm_bat.with_suffix(f".bak{int(time.time())}")
|
||||||
mm_ps1.write_text(ps1_text, encoding="utf-8")
|
mm_bat.replace(bak)
|
||||||
|
mm_bat.write_text(bat_text, encoding="utf-8")
|
||||||
|
|
||||||
# Validate that the PowerShell shim was created correctly
|
# Validate that the batch shim was created correctly
|
||||||
ps1_ok = mm_ps1.exists() and len(mm_ps1.read_text(encoding="utf-8")) > 0
|
bat_ok = mm_bat.exists() and len(mm_bat.read_text(encoding="utf-8")) > 0
|
||||||
if not ps1_ok:
|
if not bat_ok:
|
||||||
raise RuntimeError("Failed to create mm.ps1 shim")
|
raise RuntimeError("Failed to create mm.bat shim")
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
print(f"DEBUG: Created mm.ps1 ({len(ps1_text)} bytes)")
|
print(f"DEBUG: Created mm.bat ({len(bat_text)} bytes)")
|
||||||
print(f"DEBUG: Repo path embedded in shim: {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