fix: change CWD to /tmp in _ensure_yarn_installed

All yarn/npm commands now run from /tmp to completely avoid workspace
package.json with patch: entries. Restores original CWD after install.
This commit is contained in:
iamninja committed 2026-10-05 15:21:57 +05:00
1 parent c5afd450f5
commit 2b92e7b6d6
1 file changed
+12 -5
+12 -5
View File
@@ -2142,6 +2142,10 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
step_msg = f"Reinstalling Yarn 4.x (attempt {retry_count + 1}/{max_retries + 1})"
with step(step_msg):
# Change CWD to /tmp to avoid workspace/package.json issues
original_cwd = os.getcwd()
os.chdir("/tmp")
# Cleanup on retry
if retry_count > 0:
_cleanup_yarn_artifacts()
@@ -2199,10 +2203,11 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
if shutil.which("yarn"):
major = _get_yarn_major_version(["yarn"])
if major and major >= 4:
if DEBUG:
print(f" ✓ Yarn {major}.x installed via corepack")
return True
if major and major >= 4:
if DEBUG:
print(f" ✓ Yarn {major}.x installed via corepack")
os.chdir(original_cwd)
return True
except Exception as e:
if DEBUG:
print(f" ⚠ Corepack method failed: {e}")
@@ -2245,7 +2250,8 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
if major and major >= 4:
if DEBUG:
print(f" ✓ Yarn {major}.x installed via @yarnpkg/cli")
print(f" ✓ Yarn {major}.x installed via 'yarn set version'")
os.chdir(original_cwd)
return True
except Exception as e:
if DEBUG:
@@ -2297,6 +2303,7 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
if DEBUG:
print(f" ⚠ 'yarn set version' failed: {e}")
os.chdir(original_cwd)
return False
# Main logic: Find or install Yarn 4.x