From c2c3ce7b0bb2ede980b47b0882e2e37c67696b08 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 11:31:36 -0600 Subject: [PATCH 01/12] ci(fix): mock .exe files for Windows? --- .../hoisted/node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ .../turbo/node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../turbo/node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ .../find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../self/node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-64/bin/turbo.exe | 2 ++ .../node_modules/turbo-windows-arm64/bin/turbo.exe | 2 ++ 14 files changed, 28 insertions(+) create mode 100644 turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe create mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe diff --git a/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe new file mode 100644 index 0000000000000..4a4a371790b2f --- /dev/null +++ b/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe @@ -0,0 +1,2 @@ +@echo off +echo %* From d35a2ee2d995ab5cf01e51d351bbc08ab339705b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 12:02:44 -0600 Subject: [PATCH 02/12] WIP 8cd96 --- .../src/shim/local_turbo_state.rs | 20 ++++++++++-- .../integration/tests/find-turbo/linked.t | 32 ++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index 760986fb212bf..66023e7f3a8d6 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -117,6 +117,11 @@ impl LocalTurboState { let platform_package_name = TurboState::platform_package_name(); let binary_name = TurboState::binary_name(); + debug!( + "Searching for local turbo. Platform: {}, Binary: {}", + platform_package_name, binary_name + ); + let platform_package_json_path_components = [platform_package_name, "package.json"]; let platform_package_executable_path_components = [platform_package_name, "bin", binary_name]; @@ -131,13 +136,20 @@ impl LocalTurboState { // Detecting the package manager is more expensive than just doing an exhaustive // search. - for root in search_functions + for (idx, root) in search_functions .iter() .filter_map(|search_function| search_function(root_path)) + .enumerate() { + debug!("Trying search path #{}: {}", idx + 1, root); // Needs borrow because of the loop. #[allow(clippy::needless_borrow)] let bin_path = root.join_components(&platform_package_executable_path_components); + debug!("Looking for binary at: {}", bin_path); + + let exists = bin_path.exists(); + debug!("Binary exists: {}", exists); + match fs_canonicalize(&bin_path) { Ok(bin_path) => { let resolved_package_json_path = @@ -153,10 +165,14 @@ impl LocalTurboState { version: local_version, }); } - Err(_) => debug!("No local turbo binary found at: {}", bin_path), + Err(e) => debug!( + "No local turbo binary found at: {} (error: {})", + bin_path, e + ), } } + debug!("No local turbo found after searching all paths"); None } diff --git a/turborepo-tests/integration/tests/find-turbo/linked.t b/turborepo-tests/integration/tests/find-turbo/linked.t index 29c6173ef9439..315c86a2ec415 100644 --- a/turborepo-tests/integration/tests/find-turbo/linked.t +++ b/turborepo-tests/integration/tests/find-turbo/linked.t @@ -4,14 +4,38 @@ Setup Make sure we use local, but do not pass --skip-infer to old binary $ ${TESTDIR}/set_version.sh $(pwd) "1.0.0" - $ ${TURBO} build --filter foo -vv > out.log 2>&1 - $ grep --quiet -F "Local turbo version: 1.0.0" out.log + $ echo "Running turbo with verbose output..." + Running turbo with verbose output... + $ ${TURBO} build --filter foo -vv 2>&1 | tee out.log + * (glob) + $ echo "=== Full output from out.log ===" + === Full output from out.log === + $ cat out.log + * (glob) + $ echo "=== Checking for version string ===" + === Checking for version string === + $ grep -F "Local turbo version: 1.0.0" out.log || echo "VERSION STRING NOT FOUND" + * (glob) + $ echo "=== Last line of output ===" + === Last line of output === $ cat out.log | tail -n1 build --filter foo -vv -- Make sure we use local, and DO pass --skip-infer to newer binary $ ${TESTDIR}/set_version.sh $(pwd) "1.8.0" - $ ${TURBO} build --filter foo -vv > out.log 2>&1 - $ grep --quiet -F "Local turbo version: 1.8.0" out.log + $ echo "Running turbo with newer version..." + Running turbo with newer version... + $ ${TURBO} build --filter foo -vv 2>&1 | tee out.log + * (glob) + $ echo "=== Full output from out.log ===" + === Full output from out.log === + $ cat out.log + * (glob) + $ echo "=== Checking for version string ===" + === Checking for version string === + $ grep -F "Local turbo version: 1.8.0" out.log || echo "VERSION STRING NOT FOUND" + * (glob) + $ echo "=== Last line of output ===" + === Last line of output === $ cat out.log | tail -n1 --skip-infer build --filter foo -vv --single-package -- From 907a38b585c1dac5e5bb925324f806d2035f6950 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 12:49:17 -0600 Subject: [PATCH 03/12] WIP acc1b --- .../integration/tests/find-turbo/linked.t | 9 +++++ .../integration/tests/find-turbo/setup.sh | 34 +++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/turborepo-tests/integration/tests/find-turbo/linked.t b/turborepo-tests/integration/tests/find-turbo/linked.t index 315c86a2ec415..be0e40d988a76 100644 --- a/turborepo-tests/integration/tests/find-turbo/linked.t +++ b/turborepo-tests/integration/tests/find-turbo/linked.t @@ -1,6 +1,15 @@ Setup $ . ${TESTDIR}/../../../helpers/setup.sh $ . ${TESTDIR}/setup.sh $(pwd) "linked" + * (glob) + $ echo "=== Verifying fixture state after setup ===" + === Verifying fixture state after setup === + $ ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo does not exist" + * (glob) + $ ls -la node_modules/.pnpm 2>&1 | head -5 + * (glob) + $ echo "=== End verification ===" + === End verification === Make sure we use local, but do not pass --skip-infer to old binary $ ${TESTDIR}/set_version.sh $(pwd) "1.0.0" diff --git a/turborepo-tests/integration/tests/find-turbo/setup.sh b/turborepo-tests/integration/tests/find-turbo/setup.sh index 387b9c37e14d4..c0fed04b2052d 100644 --- a/turborepo-tests/integration/tests/find-turbo/setup.sh +++ b/turborepo-tests/integration/tests/find-turbo/setup.sh @@ -5,6 +5,10 @@ SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) TARGET_DIR=$1 FIXTURE_DIR=$2 +echo "=== Setup starting for fixture: $FIXTURE_DIR ===" +echo "OSTYPE: $OSTYPE" +echo "TARGET_DIR: $TARGET_DIR" + cp -a ${SCRIPT_DIR}/../../fixtures/find_turbo/$FIXTURE_DIR/. ${TARGET_DIR}/ # We need to symlink: turbo -> .pnpm/turbo@1.0.0/node_modules/turbo @@ -12,18 +16,44 @@ cp -a ${SCRIPT_DIR}/../../fixtures/find_turbo/$FIXTURE_DIR/. ${TARGET_DIR}/ # and `.pnpm/turbo@1.0.0/node_modules/turbo` is the path to symlink to # Note: using a nested if so it's easy to find the Windows checks in scripts around the codebase. if [[ "$OSTYPE" == "msys" ]]; then + echo "Running on Windows (msys)" if [[ $FIXTURE_DIR == "linked" ]]; then + echo "Setting up linked fixture for Windows..." + + # Check what exists before we start + echo "Before setup:" + ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo does not exist" + ls -la node_modules/.pnpm/turbo@1.0.0/node_modules/turbo 2>&1 || echo "pnpm turbo directory does not exist" + # Delete the existing turbo directory or file, whatever exists there + echo "Removing existing node_modules/turbo..." rm -rf node_modules/turbo # Let's enter the node_modules directory - # echo "entering node_modules directory" + echo "Entering node_modules directory..." pushd node_modules > /dev/null || exit 1 # Use pnpx to run symlnk-dir because installing globally doesn't work with pnpm. - pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo > /dev/null 2>&1 + echo "Attempting to create symlink with: pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo" + if pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo; then + echo "✓ Symlink created successfully" + else + EXIT_CODE=$? + echo "✗ Symlink creation FAILED with exit code: $EXIT_CODE" + fi # Get outta there popd > /dev/null || exit 1 + + # Verify what we ended up with + echo "After setup:" + ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo still does not exist" + if [ -L node_modules/turbo ]; then + echo "node_modules/turbo is a symlink pointing to: $(readlink node_modules/turbo)" + fi + + echo "=== Setup complete ===" fi +else + echo "Not running on Windows, skipping Windows-specific setup" fi From 41069defae12333c6b3ea7bad2618d6e320ecde6 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 13:14:21 -0600 Subject: [PATCH 04/12] WIP 65025 --- .../integration/tests/find-turbo/setup.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/turborepo-tests/integration/tests/find-turbo/setup.sh b/turborepo-tests/integration/tests/find-turbo/setup.sh index c0fed04b2052d..1ab5ae09a9bfe 100644 --- a/turborepo-tests/integration/tests/find-turbo/setup.sh +++ b/turborepo-tests/integration/tests/find-turbo/setup.sh @@ -11,6 +11,16 @@ echo "TARGET_DIR: $TARGET_DIR" cp -a ${SCRIPT_DIR}/../../fixtures/find_turbo/$FIXTURE_DIR/. ${TARGET_DIR}/ +# Verify what got copied +echo "Checking .pnpm contents after cp:" +ls -la ${TARGET_DIR}/node_modules/.pnpm/ 2>&1 || echo ".pnpm directory does not exist" +if [ -d "${TARGET_DIR}/node_modules/.pnpm/turbo@1.0.0" ]; then + echo "turbo@1.0.0 directory exists" + ls -la ${TARGET_DIR}/node_modules/.pnpm/turbo@1.0.0/node_modules/ 2>&1 || echo "node_modules subdirectory missing" +else + echo "ERROR: turbo@1.0.0 directory was NOT copied!" +fi + # We need to symlink: turbo -> .pnpm/turbo@1.0.0/node_modules/turbo # where `turbo` is the symlink # and `.pnpm/turbo@1.0.0/node_modules/turbo` is the path to symlink to @@ -49,7 +59,12 @@ if [[ "$OSTYPE" == "msys" ]]; then echo "After setup:" ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo still does not exist" if [ -L node_modules/turbo ]; then - echo "node_modules/turbo is a symlink pointing to: $(readlink node_modules/turbo)" + LINK_TARGET=$(readlink node_modules/turbo) + echo "node_modules/turbo is a symlink pointing to: $LINK_TARGET" + echo "Checking if symlink target exists:" + ls -la "node_modules/$LINK_TARGET" 2>&1 || echo "ERROR: Symlink target does NOT exist!" + echo "Checking if we can find turbo-windows-64 from the symlink target:" + ls -la "node_modules/$LINK_TARGET/../turbo-windows-64" 2>&1 || echo "ERROR: turbo-windows-64 not found relative to symlink target" fi echo "=== Setup complete ===" From 77ef4bbaad2679a65c2eb93ea88b3d9f31cf0d0c Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 13:51:28 -0600 Subject: [PATCH 05/12] WIP d3d02 --- .../src/shim/local_turbo_state.rs | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index 66023e7f3a8d6..552445937aba5 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -59,10 +59,57 @@ impl LocalTurboState { // leading to the wrong place. We could separate the Windows // implementation, but this workaround works for other platforms as // well. - let canonical_path = - fs_canonicalize(root_path.as_path().join("node_modules").join("turbo")).ok()?; + let turbo_path = root_path.as_path().join("node_modules").join("turbo"); + debug!( + "generate_linked_path: Attempting to canonicalize: {}", + turbo_path.display() + ); - AbsoluteSystemPathBuf::try_from(canonical_path.parent()?).ok() + match fs_canonicalize(&turbo_path) { + Ok(canonical_path) => { + debug!( + "generate_linked_path: Canonicalized to: {}", + canonical_path.display() + ); + match canonical_path.parent() { + Some(parent) => { + debug!( + "generate_linked_path: Parent directory: {}", + parent.display() + ); + match AbsoluteSystemPathBuf::try_from(parent) { + Ok(path) => { + debug!( + "generate_linked_path: Successfully created \ + AbsoluteSystemPathBuf" + ); + Some(path) + } + Err(e) => { + debug!( + "generate_linked_path: Failed to create \ + AbsoluteSystemPathBuf: {:?}", + e + ); + None + } + } + } + None => { + debug!("generate_linked_path: Canonicalized path has no parent"); + None + } + } + } + Err(e) => { + debug!( + "generate_linked_path: Failed to canonicalize {}: {}", + turbo_path.display(), + e + ); + None + } + } } // The unplugged directory doesn't have a fixed path. From 0dc95ae065538f1f75bc5498a9f7d0f704a5c659 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 14:18:11 -0600 Subject: [PATCH 06/12] WIP 7fa9a --- crates/turborepo-lib/src/shim/local_turbo_state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index 552445937aba5..dd0ae6b7e4700 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -62,7 +62,7 @@ impl LocalTurboState { let turbo_path = root_path.as_path().join("node_modules").join("turbo"); debug!( "generate_linked_path: Attempting to canonicalize: {}", - turbo_path.display() + turbo_path.as_str() ); match fs_canonicalize(&turbo_path) { @@ -104,7 +104,7 @@ impl LocalTurboState { Err(e) => { debug!( "generate_linked_path: Failed to canonicalize {}: {}", - turbo_path.display(), + turbo_path.as_str(), e ); None From 2406bfef68b88ad6c6ae873b201fc04b5be94fb1 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 20:12:11 -0600 Subject: [PATCH 07/12] first try at a real fix --- .../src/shim/local_turbo_state.rs | 72 +++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index dd0ae6b7e4700..2921e269377a6 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -62,7 +62,7 @@ impl LocalTurboState { let turbo_path = root_path.as_path().join("node_modules").join("turbo"); debug!( "generate_linked_path: Attempting to canonicalize: {}", - turbo_path.as_str() + turbo_path ); match fs_canonicalize(&turbo_path) { @@ -104,10 +104,74 @@ impl LocalTurboState { Err(e) => { debug!( "generate_linked_path: Failed to canonicalize {}: {}", - turbo_path.as_str(), - e + turbo_path, e ); - None + + // On Windows, canonicalize can fail with permission errors even when + // the symlink is valid. Try using read_link instead. + #[cfg(target_os = "windows")] + { + debug!("generate_linked_path: Attempting Windows fallback with read_link"); + match fs::read_link(&turbo_path) { + Ok(link_target) => { + debug!( + "generate_linked_path: read_link succeeded, target: {}", + link_target.display() + ); + + // The link target is relative to the symlink location + // e.g., ".pnpm/turbo@1.0.0/node_modules/turbo" + // We need to resolve it relative to node_modules directory + let node_modules = root_path.as_path().join("node_modules"); + let resolved = node_modules.join(&link_target); + + debug!( + "generate_linked_path: Resolved path: {}", + resolved.display() + ); + + // Get the parent directory (should be .pnpm/turbo@1.0.0/node_modules) + match resolved.parent() { + Some(parent) => { + debug!( + "generate_linked_path: Parent directory: {}", + parent.display() + ); + match AbsoluteSystemPathBuf::try_from(parent) { + Ok(path) => { + debug!( + "generate_linked_path: Successfully created \ + AbsoluteSystemPathBuf from read_link fallback" + ); + Some(path) + } + Err(e) => { + debug!( + "generate_linked_path: Failed to create \ + AbsoluteSystemPathBuf: {:?}", + e + ); + None + } + } + } + None => { + debug!("generate_linked_path: Resolved path has no parent"); + None + } + } + } + Err(e) => { + debug!("generate_linked_path: read_link also failed: {}", e); + None + } + } + } + + #[cfg(not(target_os = "windows"))] + { + None + } } } } From 054ce70e1524f8c896f3f92b9dccd6883bd91f78 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 20:39:15 -0600 Subject: [PATCH 08/12] WIP 9e710 --- crates/turborepo-lib/src/shim/local_turbo_state.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index 2921e269377a6..edd962c1aad09 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -112,7 +112,7 @@ impl LocalTurboState { #[cfg(target_os = "windows")] { debug!("generate_linked_path: Attempting Windows fallback with read_link"); - match fs::read_link(&turbo_path) { + match fs::read_link(turbo_path.as_std_path()) { Ok(link_target) => { debug!( "generate_linked_path: read_link succeeded, target: {}", @@ -122,7 +122,8 @@ impl LocalTurboState { // The link target is relative to the symlink location // e.g., ".pnpm/turbo@1.0.0/node_modules/turbo" // We need to resolve it relative to node_modules directory - let node_modules = root_path.as_path().join("node_modules"); + let node_modules = + PathBuf::from(root_path.as_path().as_str()).join("node_modules"); let resolved = node_modules.join(&link_target); debug!( From 03f923d619e45777837ec4c3e23aeef504641c97 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 21:50:40 -0600 Subject: [PATCH 09/12] WIP 19557 --- .../integration/tests/find-turbo/setup.sh | 50 +------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/turborepo-tests/integration/tests/find-turbo/setup.sh b/turborepo-tests/integration/tests/find-turbo/setup.sh index 1ab5ae09a9bfe..04106c65ce244 100644 --- a/turborepo-tests/integration/tests/find-turbo/setup.sh +++ b/turborepo-tests/integration/tests/find-turbo/setup.sh @@ -5,70 +5,24 @@ SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) TARGET_DIR=$1 FIXTURE_DIR=$2 -echo "=== Setup starting for fixture: $FIXTURE_DIR ===" -echo "OSTYPE: $OSTYPE" -echo "TARGET_DIR: $TARGET_DIR" - cp -a ${SCRIPT_DIR}/../../fixtures/find_turbo/$FIXTURE_DIR/. ${TARGET_DIR}/ -# Verify what got copied -echo "Checking .pnpm contents after cp:" -ls -la ${TARGET_DIR}/node_modules/.pnpm/ 2>&1 || echo ".pnpm directory does not exist" -if [ -d "${TARGET_DIR}/node_modules/.pnpm/turbo@1.0.0" ]; then - echo "turbo@1.0.0 directory exists" - ls -la ${TARGET_DIR}/node_modules/.pnpm/turbo@1.0.0/node_modules/ 2>&1 || echo "node_modules subdirectory missing" -else - echo "ERROR: turbo@1.0.0 directory was NOT copied!" -fi - # We need to symlink: turbo -> .pnpm/turbo@1.0.0/node_modules/turbo # where `turbo` is the symlink # and `.pnpm/turbo@1.0.0/node_modules/turbo` is the path to symlink to # Note: using a nested if so it's easy to find the Windows checks in scripts around the codebase. if [[ "$OSTYPE" == "msys" ]]; then - echo "Running on Windows (msys)" if [[ $FIXTURE_DIR == "linked" ]]; then - echo "Setting up linked fixture for Windows..." - - # Check what exists before we start - echo "Before setup:" - ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo does not exist" - ls -la node_modules/.pnpm/turbo@1.0.0/node_modules/turbo 2>&1 || echo "pnpm turbo directory does not exist" - # Delete the existing turbo directory or file, whatever exists there - echo "Removing existing node_modules/turbo..." rm -rf node_modules/turbo # Let's enter the node_modules directory - echo "Entering node_modules directory..." pushd node_modules > /dev/null || exit 1 - # Use pnpx to run symlnk-dir because installing globally doesn't work with pnpm. - echo "Attempting to create symlink with: pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo" - if pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo; then - echo "✓ Symlink created successfully" - else - EXIT_CODE=$? - echo "✗ Symlink creation FAILED with exit code: $EXIT_CODE" - fi + # Use pnpx to run symlink-dir because installing globally doesn't work with pnpm. + pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo > /dev/null 2>&1 # Get outta there popd > /dev/null || exit 1 - - # Verify what we ended up with - echo "After setup:" - ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo still does not exist" - if [ -L node_modules/turbo ]; then - LINK_TARGET=$(readlink node_modules/turbo) - echo "node_modules/turbo is a symlink pointing to: $LINK_TARGET" - echo "Checking if symlink target exists:" - ls -la "node_modules/$LINK_TARGET" 2>&1 || echo "ERROR: Symlink target does NOT exist!" - echo "Checking if we can find turbo-windows-64 from the symlink target:" - ls -la "node_modules/$LINK_TARGET/../turbo-windows-64" 2>&1 || echo "ERROR: turbo-windows-64 not found relative to symlink target" - fi - - echo "=== Setup complete ===" fi -else - echo "Not running on Windows, skipping Windows-specific setup" fi From 7149bfacc3b6b59253ea70c10ba1a6edfffd7827 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 22:18:47 -0600 Subject: [PATCH 10/12] WIP 19715 --- .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../turbo-windows-64/bin/turbo.exe | 2 - .../turbo-windows-arm64/bin/turbo.exe | 2 - .../integration/tests/find-turbo/linked.t | 41 ++----------------- .../integration/tests/find-turbo/setup.sh | 3 +- 16 files changed, 6 insertions(+), 66 deletions(-) delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe delete mode 100644 turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe diff --git a/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/hoisted/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-64@1.0.0/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/linked/node_modules/.pnpm/turbo-windows-arm64@1.0.0/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/nested/node_modules/turbo/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/self/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/unplugged/.yarn/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/unplugged_env_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-64-npm-1.0.0-520925a700/node_modules/turbo-windows-64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe b/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe deleted file mode 100644 index 4a4a371790b2f..0000000000000 --- a/turborepo-tests/integration/fixtures/find_turbo/unplugged_moved/.moved/unplugged/turbo-windows-arm64-npm-1.0.0-520925a700/node_modules/turbo-windows-arm64/bin/turbo.exe +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -echo %* diff --git a/turborepo-tests/integration/tests/find-turbo/linked.t b/turborepo-tests/integration/tests/find-turbo/linked.t index be0e40d988a76..29c6173ef9439 100644 --- a/turborepo-tests/integration/tests/find-turbo/linked.t +++ b/turborepo-tests/integration/tests/find-turbo/linked.t @@ -1,50 +1,17 @@ Setup $ . ${TESTDIR}/../../../helpers/setup.sh $ . ${TESTDIR}/setup.sh $(pwd) "linked" - * (glob) - $ echo "=== Verifying fixture state after setup ===" - === Verifying fixture state after setup === - $ ls -la node_modules/turbo 2>&1 || echo "node_modules/turbo does not exist" - * (glob) - $ ls -la node_modules/.pnpm 2>&1 | head -5 - * (glob) - $ echo "=== End verification ===" - === End verification === Make sure we use local, but do not pass --skip-infer to old binary $ ${TESTDIR}/set_version.sh $(pwd) "1.0.0" - $ echo "Running turbo with verbose output..." - Running turbo with verbose output... - $ ${TURBO} build --filter foo -vv 2>&1 | tee out.log - * (glob) - $ echo "=== Full output from out.log ===" - === Full output from out.log === - $ cat out.log - * (glob) - $ echo "=== Checking for version string ===" - === Checking for version string === - $ grep -F "Local turbo version: 1.0.0" out.log || echo "VERSION STRING NOT FOUND" - * (glob) - $ echo "=== Last line of output ===" - === Last line of output === + $ ${TURBO} build --filter foo -vv > out.log 2>&1 + $ grep --quiet -F "Local turbo version: 1.0.0" out.log $ cat out.log | tail -n1 build --filter foo -vv -- Make sure we use local, and DO pass --skip-infer to newer binary $ ${TESTDIR}/set_version.sh $(pwd) "1.8.0" - $ echo "Running turbo with newer version..." - Running turbo with newer version... - $ ${TURBO} build --filter foo -vv 2>&1 | tee out.log - * (glob) - $ echo "=== Full output from out.log ===" - === Full output from out.log === - $ cat out.log - * (glob) - $ echo "=== Checking for version string ===" - === Checking for version string === - $ grep -F "Local turbo version: 1.8.0" out.log || echo "VERSION STRING NOT FOUND" - * (glob) - $ echo "=== Last line of output ===" - === Last line of output === + $ ${TURBO} build --filter foo -vv > out.log 2>&1 + $ grep --quiet -F "Local turbo version: 1.8.0" out.log $ cat out.log | tail -n1 --skip-infer build --filter foo -vv --single-package -- diff --git a/turborepo-tests/integration/tests/find-turbo/setup.sh b/turborepo-tests/integration/tests/find-turbo/setup.sh index 04106c65ce244..387b9c37e14d4 100644 --- a/turborepo-tests/integration/tests/find-turbo/setup.sh +++ b/turborepo-tests/integration/tests/find-turbo/setup.sh @@ -17,9 +17,10 @@ if [[ "$OSTYPE" == "msys" ]]; then rm -rf node_modules/turbo # Let's enter the node_modules directory + # echo "entering node_modules directory" pushd node_modules > /dev/null || exit 1 - # Use pnpx to run symlink-dir because installing globally doesn't work with pnpm. + # Use pnpx to run symlnk-dir because installing globally doesn't work with pnpm. pnpx symlink-dir .pnpm/turbo@1.0.0/node_modules/turbo turbo > /dev/null 2>&1 # Get outta there From 280a803fe6aa8f52e3584f91eb797a3a851d4e71 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 22:43:37 -0600 Subject: [PATCH 11/12] WIP 0a200 --- .../src/shim/local_turbo_state.rs | 120 ++---------------- 1 file changed, 11 insertions(+), 109 deletions(-) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index edd962c1aad09..1045603aa6015 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -60,65 +60,19 @@ impl LocalTurboState { // implementation, but this workaround works for other platforms as // well. let turbo_path = root_path.as_path().join("node_modules").join("turbo"); - debug!( - "generate_linked_path: Attempting to canonicalize: {}", - turbo_path - ); match fs_canonicalize(&turbo_path) { - Ok(canonical_path) => { - debug!( - "generate_linked_path: Canonicalized to: {}", - canonical_path.display() - ); - match canonical_path.parent() { - Some(parent) => { - debug!( - "generate_linked_path: Parent directory: {}", - parent.display() - ); - match AbsoluteSystemPathBuf::try_from(parent) { - Ok(path) => { - debug!( - "generate_linked_path: Successfully created \ - AbsoluteSystemPathBuf" - ); - Some(path) - } - Err(e) => { - debug!( - "generate_linked_path: Failed to create \ - AbsoluteSystemPathBuf: {:?}", - e - ); - None - } - } - } - None => { - debug!("generate_linked_path: Canonicalized path has no parent"); - None - } - } - } - Err(e) => { - debug!( - "generate_linked_path: Failed to canonicalize {}: {}", - turbo_path, e - ); - + Ok(canonical_path) => match canonical_path.parent() { + Some(parent) => AbsoluteSystemPathBuf::try_from(parent).ok(), + None => None, + }, + Err(_) => { // On Windows, canonicalize can fail with permission errors even when // the symlink is valid. Try using read_link instead. #[cfg(target_os = "windows")] { - debug!("generate_linked_path: Attempting Windows fallback with read_link"); match fs::read_link(turbo_path.as_std_path()) { Ok(link_target) => { - debug!( - "generate_linked_path: read_link succeeded, target: {}", - link_target.display() - ); - // The link target is relative to the symlink location // e.g., ".pnpm/turbo@1.0.0/node_modules/turbo" // We need to resolve it relative to node_modules directory @@ -126,46 +80,12 @@ impl LocalTurboState { PathBuf::from(root_path.as_path().as_str()).join("node_modules"); let resolved = node_modules.join(&link_target); - debug!( - "generate_linked_path: Resolved path: {}", - resolved.display() - ); - // Get the parent directory (should be .pnpm/turbo@1.0.0/node_modules) - match resolved.parent() { - Some(parent) => { - debug!( - "generate_linked_path: Parent directory: {}", - parent.display() - ); - match AbsoluteSystemPathBuf::try_from(parent) { - Ok(path) => { - debug!( - "generate_linked_path: Successfully created \ - AbsoluteSystemPathBuf from read_link fallback" - ); - Some(path) - } - Err(e) => { - debug!( - "generate_linked_path: Failed to create \ - AbsoluteSystemPathBuf: {:?}", - e - ); - None - } - } - } - None => { - debug!("generate_linked_path: Resolved path has no parent"); - None - } - } - } - Err(e) => { - debug!("generate_linked_path: read_link also failed: {}", e); - None + resolved + .parent() + .and_then(|parent| AbsoluteSystemPathBuf::try_from(parent).ok()) } + Err(_) => None, } } @@ -229,11 +149,6 @@ impl LocalTurboState { let platform_package_name = TurboState::platform_package_name(); let binary_name = TurboState::binary_name(); - debug!( - "Searching for local turbo. Platform: {}, Binary: {}", - platform_package_name, binary_name - ); - let platform_package_json_path_components = [platform_package_name, "package.json"]; let platform_package_executable_path_components = [platform_package_name, "bin", binary_name]; @@ -248,20 +163,13 @@ impl LocalTurboState { // Detecting the package manager is more expensive than just doing an exhaustive // search. - for (idx, root) in search_functions + for root in search_functions .iter() .filter_map(|search_function| search_function(root_path)) - .enumerate() { - debug!("Trying search path #{}: {}", idx + 1, root); // Needs borrow because of the loop. #[allow(clippy::needless_borrow)] let bin_path = root.join_components(&platform_package_executable_path_components); - debug!("Looking for binary at: {}", bin_path); - - let exists = bin_path.exists(); - debug!("Binary exists: {}", exists); - match fs_canonicalize(&bin_path) { Ok(bin_path) => { let resolved_package_json_path = @@ -270,21 +178,15 @@ impl LocalTurboState { PackageJson::load(&resolved_package_json_path).ok()?; let local_version = platform_package_json.version?; - debug!("Local turbo path: {}", bin_path.display()); - debug!("Local turbo version: {}", &local_version); return Some(Self { bin_path, version: local_version, }); } - Err(e) => debug!( - "No local turbo binary found at: {} (error: {})", - bin_path, e - ), + Err(_) => debug!("No local turbo binary found at: {}", bin_path), } } - debug!("No local turbo found after searching all paths"); None } From 1f5cafce60f7efe00fcf3882e73cd7e5ad68124b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 17 Oct 2025 22:45:45 -0600 Subject: [PATCH 12/12] WIP 935c0 --- crates/turborepo-lib/src/shim/local_turbo_state.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/turborepo-lib/src/shim/local_turbo_state.rs b/crates/turborepo-lib/src/shim/local_turbo_state.rs index 1045603aa6015..7313c0550db9e 100644 --- a/crates/turborepo-lib/src/shim/local_turbo_state.rs +++ b/crates/turborepo-lib/src/shim/local_turbo_state.rs @@ -178,6 +178,8 @@ impl LocalTurboState { PackageJson::load(&resolved_package_json_path).ok()?; let local_version = platform_package_json.version?; + debug!("Local turbo path: {}", bin_path.display()); + debug!("Local turbo version: {}", &local_version); return Some(Self { bin_path, version: local_version,