diff --git a/npm_install.py b/npm_install.py index 853b764..a46f68f 100644 --- a/npm_install.py +++ b/npm_install.py @@ -2003,23 +2003,22 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): if DEBUG: print(f" debug pick: yarn_bin={yarn_bin} HANGS, skipping") - # Use npm exec directly (bypasses broken corepack proxy) - if shutil.which("npm"): + # Use corepack yarn directly (bypasses broken corepack proxy) + if shutil.which("corepack") and shutil.which("npm"): try: result = subprocess.run( - ["npm", "exec", "--yes", "yarn@stable", "--", "--version"], - capture_output=True, text=True, timeout=30, + ["corepack", "yarn", "--version"], + capture_output=True, text=True, timeout=15, ) if DEBUG: - print(f" debug pick: npm exec version={result.stdout.strip()} rc={result.returncode}") - major = _get_yarn_major_version(["npm", "exec", "--yes", "yarn@stable", "--"]) - if major and major >= 4: - if DEBUG: - print(f" debug pick: using npm exec for yarn") - return ["npm", "exec", "--yes", "yarn@stable", "--"] + print(f" debug pick: corepack yarn version={result.stdout.strip()} rc={result.returncode}") + if result.returncode == 0: + match = re.match(r'^(\d+)', result.stdout.strip()) + if match and int(match.group(1)) >= 4: + return ["corepack", "yarn"] except Exception as e: if DEBUG: - print(f" debug pick: npm exec failed: {e}") + print(f" debug pick: corepack yarn failed: {e}") pass return None