Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: REGRESSION: [email protected] breaks wireit in workspaces #5925

Closed
1 task
appsforartists opened this issue Nov 3, 2023 · 3 comments
Closed
1 task
Labels
bug Something isn't working

Comments

@appsforartists
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

wireit uses the yarn run -TB wireit command to access its own binary from any part of the workspace. It pulls the package.json from your current directory and runs the specified script.

In prior versions of yarn (e.g. 3.2.1), this worked. In 4.0.1, every script is run as if the current directory is the workspace root.

cc @aomarks

To reproduce

# failure in 4.0.1
> mkdir -p test/packages/inner
> echo '{"workspaces":["packages/*"],"scripts":{"test-direct":"echo \"hi from yarn@root\"","test-wireit":"yarn run -TB wireit"},"wireit":{"test-wireit":{"command":"echo \"hi from wireit@root\""}},"devDependencies":{"wireit": "0.7.1"}}' > test/package.json
> echo '{"workspaces":["packages/*"],"scripts":{"test-direct":"echo \"hi from yarn@inner\"","test-wireit":"yarn run -TB wireit"},"wireit":{"test-wireit":{"command":"echo \"hi from wireit@inner\""}}}' > test/packages/inner/package.json
> cd test
> yarn set version 4.0.1
> yarn
> cd packages/inner/
> yarn run test-direct
hi from yarn@inner
> yarn run test-wireit
🏃 [test-wireit] Running command "echo "hi from wireit@root"" ❌❌ this should be @inner
hi from wireit@root 
✅ [test-wireit] Executed successfully
# success in 3.2.1
> mkdir -p test/packages/inner
> echo '{"workspaces":["packages/*"],"scripts":{"test-direct":"echo \"hi from yarn@root\"","test-wireit":"yarn run -TB wireit"},"wireit":{"test-wireit":{"command":"echo \"hi from wireit@root\""}},"devDependencies":{"wireit": "0.7.1"}}' > test/package.json
> echo '{"workspaces":["packages/*"],"scripts":{"test-direct":"echo \"hi from yarn@inner\"","test-wireit":"yarn run -TB wireit"},"wireit":{"test-wireit":{"command":"echo \"hi from wireit@inner\""}}}' > test/packages/inner/package.json
> cd test
> curl -o ./yarn-3.2.1.js https://raw.githubusercontent.com/material-foundation/trapeze/71eb1dd3da3ad00eacb90d6087eb5f13a396b575/third_party/.yarn/releases/yarn-3.2.1.cjs
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2121k  100 2121k    0     0  3000k      0 --:--:-- --:--:-- --:--:-- 3018k
> echo -e "nodeLinker: node-modules \nyarnPath: "$PWD"/yarn-3.2.1.js" > .yarnrc.yml
> yarn
➤ YN0000: ┌ Resolution step
➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged
➤ YN0000: └ Completed in 2s 60ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ which@npm:4.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wireit@npm:0.7.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wrap-ansi@npm:7.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wrap-ansi@npm:8.1.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yallist@npm:4.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 0s 243ms
➤ YN0000: Done with warnings in 2s 428ms
> cd packages/inner/
> yarn run test-direct
hi from yarn@inner
> yarn run test-wireit
🏃 [test-wireit] Running command "echo "hi from wireit@inner""
hi from wireit@inner
✅ [test-wireit] Executed successfully

Note: yarn use version 3.2.1 was setting 4.0.1, so I'm manually curling the old version.

Environment

System:
    OS: macOS 14.1
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 20.9.0 - /private/var/folders/p0/kbnclsq57q96dg1kd3699mvc00_vh7/T/xfs-6bd828f5/node
    Yarn: 3.2.1 - /private/var/folders/p0/kbnclsq57q96dg1kd3699mvc00_vh7/T/xfs-6bd828f5/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 8.10.0 - ~/.nvm/versions/node/v20.9.0/bin/pnpm

Additional context

No response

@arcanis
Copy link
Member

arcanis commented Nov 3, 2023

Closing as duplicate of #5750

@arcanis arcanis closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2023
@arcanis
Copy link
Member

arcanis commented Nov 3, 2023

Actually no, it's something different unrelated to Yarn 4. If you update your example to use 3.2.2, you'll see the same thing. I'm not sure what changed that, but it's been there for a good chunk of time already (3.2.2 was released Jul 21, 2022). I'll investigate a little to better understand whether it's expected or not.

@arcanis
Copy link
Member

arcanis commented Nov 3, 2023

Left a note here: google/wireit#960 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants