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
Add Yarn 2+ support to pack
#1071
Conversation
Interesting, this one fails for me with:
But I think you are on the right track again here, I'll close #1060 in favour of this. I see your point on the other PR that
But I'm not sure if this is standard yarn usage or something different in our monorepo, and also not sure if |
If you were to run |
Interesting, this reveals the underlying error:
Same error with both yarn 3.2.2 and 3.3.0. Maybe a problem with the workspace? |
Is this still in-progress? |
This is working in an oclif CLI monorepo at @appfolio, but I've not had an opportunity to figure out why it isn't working for @strophy. On a previous PR also trying to fix this same issue, an engineer at Salesforce made it pretty clear that this is not a priority for them to test, review, and merge. As a result, it seems like it may be a waste of my time to continue pushing this forward. |
Got it - I'd hate to have to fork over oclif just to get support for this. We are using a monorepo with yarn berry - the only solution now is to create a nested |
Yep, sounds like you are experiencing the same problem as us @peniqliotuv @mattwebbio I discussed this with our lead engineer last week and he determined that the error I pasted above is due to oclif needing to gather some more things from the workspace into the tmp directory, either as copies or symlinks. We will continue trying to figure out a fix based on this PR. |
@mattwebbio we traced the problem above to quirks in the way our specific monorepo is set up. With additional steps on our side this PR is now tested working for us. @RodEsp Can we please get it merged? |
Yeah, it works for me as well. Please merge. |
Any update on this? |
Also I do believe for this to work, you'll need |
Co-authored-by: Jerry Tsui <tiger.tsui@gmail.com>
fab0127
to
a27d9db
Compare
@WillieRuemmele / @mdonnalley sorry for the direct ping, saw you were active maintainers |
Or @peternhale can you help maybe? (@peniqliotuv for background info I was getting good feedback from him when I first raised this issue way back in 2021) |
I really appreciate this wonderful library but I'm really disappointed by the level of responsiveness for outstanding issues, especially when it was communicated that from the release of |
Hi, any update on this? @peternhale |
@@ -66,7 +66,21 @@ export async function build(c: BuildConfig, options: { | |||
const yarnRoot = findYarnWorkspaceRoot(c.root) || c.root | |||
if (fs.existsSync(path.join(yarnRoot, 'yarn.lock'))) { | |||
await fs.copy(path.join(yarnRoot, 'yarn.lock'), path.join(c.workspace(), 'yarn.lock')) | |||
await exec('yarn --no-progress --production --non-interactive', {cwd: c.workspace()}) | |||
|
|||
const yarnVersion = (await exec('yarn -v')).stdout.charAt(0) |
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.
Hey @mattwebbio - sorry for lack of comms is yarn
guaranteed to be installed? This would throw a command not found
error if not
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.
The same issue would happen today on the production version of oclif
today. I agree that we should add a check, but if possible, that should be another PR
Hey @mattwebbio - I'm trying to verify these changes today but can't get it working. I've done the following:
using we should be able to run the |
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 was able to reproduce @WillieRuemmele 's issue with the steps provided, and confirmed that this is because of a missingworkspace-tools
plugin. There's a catch block that's supposed to identify this and print a clearer message, but it looks like it's matching on the wrong pattern. Added a comment for a guard that works for me. Another alternative would be to print this error message for any "Command failed" errors, but that would likely catch more than just missing plugins.
if (error instanceof Error && error.message.includes('Command not found')) { | ||
throw new Error('Missing workspace tools. Run `yarn plugin import workspace-tools`.') | ||
} |
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 wasn't able to get this conditional to correctly identify Command not found
errors; it seems like the resulting error's message is just Command failed
, but it has an extra property stdout
which includes the "Command not found"
substring.
This is consistent with the NodeJS docs on this usage:
In case of an error (including any error resulting in an exit code other than 0), a rejected promise is returned, with the same error object given in the callback, but with two additional properties stdout and stderr.
It's a bit verbose, but this does catch it for me:
const isCommandNotFoundError = (error: unknown): boolean => {
type ErrorWithStdout = Error & {
stdout: string;
}
const typedError = error as ErrorWithStdout
if (typedError instanceof Error && typeof typedError.stdout === 'string') {
return typedError.stdout.includes('Command not found')
}
return false
}
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.
Hi @amccarthy1 - I tried adding a simplified version of your check
const isCommandNotFoundError = (error: unknown): boolean => {
type ErrorWithStdout = Error & {
stdout: string;
}
const typedError = error as ErrorWithStdout
return typedError.stdout.includes('Command not found')
}
this worked for yarn1 and yarn3 🎉
when I was testing with yarn2, and was told to yarn plugin import workspace-tools
that command failed. I did quite a bit of researching but wasn't able to find a command or version that would install that plugin... if you can figure out a way to install workspace-tools
in yarn 2 we could add that to the error message... otherwise I think it'd be ok to continue as is.
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.
Hey @mattwebbio -
I'm trying to verify these changes today but can't get it working.
I've done the following:
- check out your fork/branch
yarn set version berry
yarn --version
=> 3.5.1yarn && yarn build
./bin/run pack:tarballs oclif: gathering workspace for oclif to /Users/william.ruemmele/projects/oclif/oclif-fork/tmp/oclif Error: Command failed: yarn workspaces focus --production at ChildProcess.exithandler (node:child_process:419:12) at ChildProcess.emit (node:events:513:28) at ChildProcess.emit (node:domain:489:12) at maybeClose (node:internal/child_process:1091:16) at Socket.<anonymous> (node:internal/child_process:449:11) at Socket.emit (node:events:513:28) at Socket.emit (node:domain:489:12) at Pipe.<anonymous> (node:net:322:12)
using
yarn 2.4.3
fails with the same error usingyarn 1.22.19
workswe should be able to run the
./bin/dev pack:tarballs
command on theoclif/oclif
repo, did I miss a step, or do something wrong? I don't think anyone on the team has adopted yarn 1+ (clearly 😜) so could be a user error too
Hi @WillieRuemmele - so I don't think that the oclif
repository will actually work with Yarn 2.
I tried the steps above and couldn't even run yarn install
(got this issue installing Typescript).
However, there does seem to be an issue with yarn >=2 <=3
when running plugin import workspace-tools
. I've opened an issue here.
Something we could do is explicitly not support yarn 2
, which seems reasonable considering that yarn >= 2
doesn't work at all today, and this issue is blocking other folks.
Hey everyone and @mattwebbio , @peniqliotuv @amccarthy1 - I created my own PR with those changes we talked about - just merged it and should be publishing as I type this |
Fixes #759
Closed #989 and updated this branch to support the deprecation of
qq
introduced in #1035.