fix: delete yarn binaries before corepack, check yarnpkg too
This commit is contained in:
1 parent
bcdcc09cce
commit
7b1b8b1b5f
1 file changed
+18
-2
+18
-2
@@ -2173,7 +2173,11 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
||||
# METHOD 1: Corepack (recommended for Yarn 4.x)
|
||||
if shutil.which("corepack"):
|
||||
try:
|
||||
# Uninstall old yarn 1.x to prevent conflicts
|
||||
# Remove all yarn binaries to avoid conflicts
|
||||
subprocess.run(["rm", "-f", "/usr/local/bin/yarn", "/usr/local/bin/yarnpkg", "/usr/bin/yarn", "/usr/bin/yarnpkg"], check=False)
|
||||
subprocess.run(["rm", "-rf", "/usr/share/yarn"], check=False)
|
||||
|
||||
# Uninstall old yarn 1.x
|
||||
subprocess.run(["npm", "uninstall", "-g", "yarn"], check=False, cwd="/tmp")
|
||||
|
||||
# Enable corepack
|
||||
@@ -2203,7 +2207,11 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
||||
)
|
||||
|
||||
# Check version
|
||||
if shutil.which("yarn"):
|
||||
yarn_bin = shutil.which("yarn")
|
||||
yarnpkg_bin = shutil.which("yarnpkg")
|
||||
if DEBUG:
|
||||
print(f" debug: which yarn={yarn_bin}, yarnpkg={yarnpkg_bin}")
|
||||
if yarn_bin:
|
||||
major = _get_yarn_major_version(["yarn"])
|
||||
|
||||
if major and major >= 4:
|
||||
@@ -2211,6 +2219,14 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path):
|
||||
print(f" ✓ Yarn {major}.x installed via corepack")
|
||||
os.chdir(original_cwd)
|
||||
return True
|
||||
|
||||
if DEBUG:
|
||||
if yarnpkg_bin:
|
||||
major = _get_yarn_major_version(["yarnpkg"])
|
||||
if major and major >= 4:
|
||||
print(f" ✓ Yarn {major}.x installed via corepack (yarnpkg)")
|
||||
os.chdir(original_cwd)
|
||||
return True
|
||||
except Exception as e:
|
||||
if DEBUG:
|
||||
print(f" ⚠ Corepack method failed: {e}")
|
||||
|
||||
Reference in new issue
Block a user