Do you want to request a feature or report a bug?
bug
What is the current behavior?
$ yarn install --focus
yarn install v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
error An unexpected error occurred: "targetHoistManifest missing".
info If you think this is a bug, please open a bug report with the information provided in "XXX\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
If the current behavior is a bug, please provide the steps to reproduce.
Unfortunately, this is in a private monorepo.
What is the expected behavior?
To install dependencies without errors.
Please mention your node.js, yarn and operating system version.
Windows 10
$ node --version
v8.9.1
$ yarn --version
1.7.0
I'm sorry I cannot provide more detailed steps to reproduce, but any help in troubleshooting this would be appreciated. For example, I don't have a clue what this error means or what could possibly cause it.
Do you have any custom .yarnrc config or anything? I think that means it can't find a package.json in the workspace root, but it's a bit hard to tell from the code...
@jonaskello I can look at this later today. It's a bug with the new --focus stuff.
If you can't provide the actual monorepo it would still be helpful to know the layout of your monorepo and how you ran the command (from what subfolder)? Like could you replace the package names with p1, p2, etc... and describe the folder structure and what versions your packages are? Also the content of your .yarnrc like @rally25rs suggested would be helpful.
Thanks!
@rally25rs the error happens due to this code in package-hoister
const targetWorkspace = path.basename(this.config.cwd);
const targetHoistManifest = this.tree.get(targetWorkspace);
invariant(targetHoistManifest, 'targetHoistManifest missing');
not sure why foo would not be in the tree if you were in the workspace foo. My guess is maybe it had a semver or something added to it, but not sure why that would happen.
I made a reproduction repo here. It was made by taking the original repo and stripping until it was a minimum. The steps to reproduce are in the README.
thanks! I'll take a look tonight.
Forgot to mention, in the packages/foo/package.json I used an existing npm package name as name (fibonacci, see here). Originally I had problems using a package name that was not published to npm (as mentioned here). Now if I change to name to foo the targetHoistManifest error goes away. Not sure what that means.
After more testing it seems the folder name of the package has to match the name of the package in package.json, otherwise I get the targetHoistManifest error. I updated the reproduction with that so now the folder is named packages/foo2 and in package.json i have name: "foo". When these to mismatch, I get the targetHoistManifest error. If I change both the folder name and the name field in package.json to the same thing the error goes away. In my original case I had scoped packages like @foo/bar but the folder was only named packages/bar.
ah yea the folder name has to match. Maybe we can remove that requirement though. That would cause the issue.
Aha, but how would I name the folder to match the package name if the package is scoped? So for example if I have name: "@foo/bar" in package.json, it is not really possible to have a folder name like @foo/bar :-). Perhaps I should have a @foo folder and under that put a bar folder?
ah yea that's a good point. the 2 folder thing wouldn't even work because it's just using basename. I'll look tonight about using the actual package name instead of the folder name. Sorry for the confusion.
Yes, just tried the 2 folder thing and it did not work :-). Anyway, thanks for working on this feature, I think it is really useful.
added #5893 which should address this issue.