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:
1 parent
c5afd450f5
commit
2b92e7b6d6
1 file changed
+8
-1
+8
-1
@@ -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})"
|
step_msg = f"Reinstalling Yarn 4.x (attempt {retry_count + 1}/{max_retries + 1})"
|
||||||
|
|
||||||
with step(step_msg):
|
with step(step_msg):
|
||||||
|
# Change CWD to /tmp to avoid workspace/package.json issues
|
||||||
|
original_cwd = os.getcwd()
|
||||||
|
os.chdir("/tmp")
|
||||||
|
|
||||||
# Cleanup on retry
|
# Cleanup on retry
|
||||||
if retry_count > 0:
|
if retry_count > 0:
|
||||||
_cleanup_yarn_artifacts()
|
_cleanup_yarn_artifacts()
|
||||||
@@ -2202,6 +2206,7 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
|||||||
if major and major >= 4:
|
if major and major >= 4:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(f" ✓ Yarn {major}.x installed via corepack")
|
print(f" ✓ Yarn {major}.x installed via corepack")
|
||||||
|
os.chdir(original_cwd)
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@@ -2245,7 +2250,8 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
|||||||
|
|
||||||
if major and major >= 4:
|
if major and major >= 4:
|
||||||
if DEBUG:
|
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
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@@ -2297,6 +2303,7 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(f" ⚠ 'yarn set version' failed: {e}")
|
print(f" ⚠ 'yarn set version' failed: {e}")
|
||||||
|
|
||||||
|
os.chdir(original_cwd)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Main logic: Find or install Yarn 4.x
|
# Main logic: Find or install Yarn 4.x
|
||||||
|
|||||||
Reference in new issue
Block a user