From a074b487b278c99e432552a29453d36cb6a57a71 Mon Sep 17 00:00:00 2001 From: stubbsta Date: Wed, 11 Jun 2025 16:08:22 +0200 Subject: [PATCH] Improve pnpm path WIP --- tests/waku_rln_relay/utils_onchain.nim | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/waku_rln_relay/utils_onchain.nim b/tests/waku_rln_relay/utils_onchain.nim index 9fd833aee..96de4ee89 100644 --- a/tests/waku_rln_relay/utils_onchain.nim +++ b/tests/waku_rln_relay/utils_onchain.nim @@ -245,7 +245,7 @@ proc deployTestToken*( debug "Submodule path verified", submodulePath = submodulePath let forgePath = getForgePath() - let pnpmPath = getPnpmPath() + var pnpmPath = getPnpmPath() debug "Forge path", forgePath debug "Pnpm path", pnpmPath @@ -280,6 +280,20 @@ proc deployTestToken*( let (installOutput, installExitCode) = execCmdEx(fmt"bash {installScriptPath}") debug "pnpm install script output", output = installOutput, exitCode = installExitCode + + # After installation, try to find the actual pnpm path + if installExitCode == 0: + let homeDir = getEnv("HOME", "") + let commonPnpmPaths = [ + joinPath(homeDir, ".local", "share", "pnpm", "pnpm"), + joinPath(homeDir, ".local", "share", "pnpm", "bin", "pnpm") + ] + + for possiblePath in commonPnpmPaths: + if fileExists(possiblePath): + debug "Found pnpm after installation", actualPath = possiblePath + pnpmPath = possiblePath + break let (pnpmInstallOutput, pnpmInstallExitCode) = execCmdEx(fmt"""cd {submodulePath} && {pnpmPath} install""") @@ -465,8 +479,23 @@ proc executeForgeContractDeployScripts*( if forgeInstallExitCode != 0: return error("forge install failed") - let pnpmPath = getPnpmPath() + var pnpmPath = getPnpmPath() debug "Pnpm path", pnpmPath + + # If we got bare "pnpm" and it might not be in PATH, try to find the actual installed path + if pnpmPath == "pnpm": + let homeDir = getEnv("HOME", "") + let commonPnpmPaths = [ + joinPath(homeDir, ".local", "share", "pnpm", "pnpm"), + joinPath(homeDir, ".local", "share", "pnpm", "bin", "pnpm") + ] + + for possiblePath in commonPnpmPaths: + if fileExists(possiblePath): + debug "Found pnpm at actual path", actualPath = possiblePath + pnpmPath = possiblePath + break + let (pnpmInstallOutput, pnpmInstallExitCode) = execCmdEx(fmt"""cd {submodulePath} && {pnpmPath} install""") trace "Executed pnpm install command", output = pnpmInstallOutput