-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(run): Include the workspace root .bin in env path #4848
Conversation
When running `yarn run` the env PATH would be set to look in node_modules/.bin, however in workspaces the root workspace .bin path was not being included. This PR adds the workspace root node_modules/.bin path after the individual package's path. Partial resolution for yarnpkg#4543
This change will increase the build size from 10.24 MB to 10.24 MB, an increase of 213 bytes (0%)
|
This is awesome! Let's add at least one test, merge from master so we get the latest CI upgrades and I'm game! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending back for tests :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me!
@BYK I finally got around to fixing this test. All ✅ now 👍 |
__tests__/commands/run.js
Outdated
const logData = logEntry ? logEntry.data.toString() : '{}'; | ||
const parsed = logEntry ? JSON.parse(logData) : {}; | ||
let envPaths = []; | ||
if (parsed.PATH) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use path.delimiter
instead. I'll go ahead and fix this myself and then merge tho :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool, I didn't even know that was a thing. Thanks!
__tests__/commands/run.js
Outdated
envPaths = parsed.Path.split(';'); | ||
} | ||
|
||
expect(envPaths).toContain(path.join(config.cwd, 'node_modules/.bin')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected this to fail on Windows since the path separator should be \
there. Weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC path.join()
converts it auto-magically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although... why didn't I do path.join(config.cwd, 'node_modules', '.bin')
? 😕 ...I'm an idiot 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, nice.
Any idea when this is going to be released? |
I cannot get this to work. Is it included in 1.3.2? UPDATE: I checked and it seems it is not in 1.3.2 but it is in 1.4.1. |
I think there was some talk about putting the release tags a merged PR is included by, like they are in commits, but for now you can check in the footer of the commit message on the page for the merge commit, which is linked in the merge message above. |
Before 1.4.0 bin commands could not be found when executed from a workspace. See yarnpkg/yarn#4848
* [core] Set required yarn version Before 1.4.0 bin commands could not be found when executed from a workspace. See yarnpkg/yarn#4848 * Revert "[core] Set required yarn version" This reverts commit e6260e3. Netlify uses 1.3.2 which has the same issue. This also limits users not just contributors. * [core] Add note about build prerequisites * Update CONTRIBUTING.md
* [core] Set required yarn version Before 1.4.0 bin commands could not be found when executed from a workspace. See yarnpkg/yarn#4848 * Revert "[core] Set required yarn version" This reverts commit e6260e3. Netlify uses 1.3.2 which has the same issue. This also limits users not just contributors. * [core] Add note about build prerequisites * Update CONTRIBUTING.md
Summary
Partial resolution for #4543.
Previously, when running
yarn run
the env PATH would be set to look in node_modules/.bin, however, in workspaces the root workspace .bin path was not being included.This PR adds the workspace root
node_modules/.bin path after the individual package's path.
This is generally needed because #4730 ensures bin links in a workspace will be at the workspace root. With this PR, you can now
yarn run
commands in an individual package again.Test plan
Manually tested by adding a script that runs
echo $PATH