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

wireit always runs from the workspace root in yarn@4 #960

Open
appsforartists opened this issue Nov 3, 2023 · 7 comments · May be fixed by #962
Open

wireit always runs from the workspace root in yarn@4 #960

appsforartists opened this issue Nov 3, 2023 · 7 comments · May be fixed by #962

Comments

@appsforartists
Copy link
Member

See yarnpkg/berry#5925

@arcanis
Copy link

arcanis commented Nov 3, 2023

It's not related to the Yarn 4.0 release, and seems to be a wireit bug. The problem started in 3.6.2, when we implemented $npm_package_json. This caused wireit to go into this branch, which is incorrect in the case of yarn run -T since the npm_package_json will be the one at the top of the repository (because of the -T).

@appsforartists
Copy link
Member Author

Thanks for investigating!

@appsforartists
Copy link
Member Author

throwing from that function doesn't interrupt the bug (and wrapping the npm_package_json in an if doesn't fix it).

That function may need to be updated, but it doesn't seem to be the cause of this bug.

@appsforartists
Copy link
Member Author

appsforartists commented Nov 3, 2023

# fail in 3.2.2
> 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.2.js https://raw.githubusercontent.com/zendesk/react-measure-timing-hooks/main/.yarn/releases/yarn-3.2.2.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.2.js" > .yarnrc.yml
> yarn
➤ YN0000: ┌ Resolution step
➤ YN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouraged
➤ YN0000: └ Completed in 5s 325ms
➤ 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 246ms
➤ YN0000: Done with warnings in 5s 726ms
> 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

@appsforartists
Copy link
Member Author

I was somehow on the last version of yarn that didn't cause this bug.

Here's the CHANGELOG for 3.2.2. Of note, it is where npm_package_json was introduced.

@appsforartists
Copy link
Member Author

appsforartists commented Nov 3, 2023

Commenting this out in 4.0.0 does fix the bug:

      // (u.npm_package_name = fn(e)), (u.npm_package_version = I);
> yarn run test-wireit
🏃 [test-wireit] Running command "echo "hi from wireit@inner""
hi from wireit@inner
✅ [test-wireit] Executed successfully
> yarn --version
4.0.0--fixing-wireit

(but weirdly not in the actual monorepo where i use yarn+wireit)

@appsforartists
Copy link
Member Author

@arcanis's issue identification was correct.

My underslept brain has been experimenting with vite serve all week, and didn't realize I'd typed yarn run serve instead of yarn run start. 🤦‍♂️

appsforartists added a commit to appsforartists/wireit that referenced this issue Nov 3, 2023
appsforartists added a commit to appsforartists/wireit that referenced this issue Nov 7, 2023
appsforartists added a commit to appsforartists/wireit that referenced this issue Jan 12, 2024
appsforartists added a commit to appsforartists/wireit that referenced this issue Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants