fix(checkYarn): Use realpath to detect corepack #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
rw
exits with a non-descript error when checking the yarn installationEven the debug log is pretty unhelpful
Just says
command failed with error
andexit status 1
.No clues as to what actually caused it to fail
With this PR you'd get a more helpful log message:
No project found in /Users/tobbe/dev/redwood/rw-cli
yarn exec <commandName> ...
And to get around the actual error I implemented a call to
realpath $(which yarn)
. If that check passes I skipyarn exec env
. If the realpath check fails the code still falls back toyarn exec env
.The usage of
yarn exec env
comes from here https://yarnpkg.com/corepack#installationBut it apparently only works if you're already in an initialized yarn project.
The "official" recommended real solution to this seems to be to enable corepack in a temp directory and use that.
nodejs/corepack#113
But before going down that route I just did the
realpath
check for now as that was much easier and faster to implement.I also asked on the yarn discord about this. See if they come back with any other ideas before we implement anything too crazy here. https://discord.com/channels/226791405589233664/654372321225605128/1205773363981848586