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

[Case Study] Something wrong with workspaces #654

Closed
zdm opened this issue Dec 29, 2019 · 9 comments
Closed

[Case Study] Something wrong with workspaces #654

zdm opened this issue Dec 29, 2019 · 9 comments
Assignees
Labels
case study Package compatibility report

Comments

@zdm
Copy link

zdm commented Dec 29, 2019

I prepared configuration, that easily allows to reporoduce the problem.

Could you, please, clone this repo git@github.com:zdm/yarn-workspace.git and run this command yarn lint from ./without-workspace/package and from ./with-workspace/package directories.

Packages are 100% identical, only single difference is that one uses workspace and other - not.

In case with workspace - package resolve error is occurred.

I don't know is it a bug or I just setup workspace incorrectly. Could you, please, make it clear?

Thank you.

@zdm zdm added the case study Package compatibility report label Dec 29, 2019
@arcanis
Copy link
Member

arcanis commented Dec 30, 2019

Note that I strongly prefer Sherlock reproduction cases to git repos. Git repos require me to create temporary directories on my local computer, review the dependencies + lockfile + cache, run an install, then figure out whether the errors I see are the one you talk about. By contrast, running a Sherlock repro is literally one command line.

Additionally, adding the exact error message in your original message would be helpful, because most of the time I can have a pretty good idea what might be wrong just be reading them.

@zdm
Copy link
Author

zdm commented Dec 30, 2019

@arcanis
I need to create workspace with the Sherlock, it is unclear how to do this?

@zdm
Copy link
Author

zdm commented Dec 30, 2019

Without workspace everything works perfectly.
In case when workspace is used I got this error:

Error: Failed to load plugin 'vue' declared in '.eslintrc.yaml » ./index.js': A package is trying to access another package without the second one being listed as a dependency of the first one

Required package: semver (via "semver")
Required by: eslint-plugin-vue@virtual:2c9a4cec8dab2bbe9df5b8caabd5cb93137949f75a7ffc7fc1f23e5f2de5b49b290d4f7efebc34a2e7705553438995ab1919ed87119a1375bf764f5c0cded111#npm:6.1.1 (via /d:/downloads/yarn-workspace/with-workspace/.yarn/virtual/eslint-plugin-vue-virtual-7a58570315/2/global-store/cache/eslint-plugin-vue-npm-6.1.1-965a2de8e5-1.zip/node_modules/eslint-plugin-vue/lib/rules/no-unsupported-features.js)

Require stack:
- d:\downloads\yarn-workspace\with-workspace\.yarn\virtual\eslint-plugin-vue-virtual-7a58570315\2\global-store\cache\eslint-plugin-vue-npm-6.1.1-965a2de8e5-1.zip\node_modules\eslint-plugin-vue\lib\rules\no-unsupported-features.js
- d:\downloads\yarn-workspace\with-workspace\.yarn\virtual\eslint-plugin-vue-virtual-7a58570315\2\global-store\cache\eslint-plugin-vue-npm-6.1.1-965a2de8e5-1.zip\node_modules\eslint-plugin-vue\lib\index.js
- d:\downloads\yarn-workspace\global-store\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\config-array-factory.js
- d:\downloads\yarn-workspace\global-store\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js
- d:\downloads\yarn-workspace\global-store\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\cli-engine.js
- d:\downloads\yarn-workspace\global-store\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\index.js
- d:\downloads\yarn-workspace\global-store\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli.js
- d:\downloads\yarn-workspace\global-store\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\bin\eslint.js
Referenced from: d:\downloads\yarn-workspace\with-workspace\package\index.js
    at internalTools_makeError (d:\downloads\yarn-workspace\with-workspace\.pnp.js:9418:24)
    at resolveToUnqualified (d:\downloads\yarn-workspace\with-workspace\.pnp.js:10398:19)
    at resolveRequest (d:\downloads\yarn-workspace\with-workspace\.pnp.js:10475:27)
    at Object.resolveRequest (d:\downloads\yarn-workspace\with-workspace\.pnp.js:10571:26)
    at Function.external_module_default.a._resolveFilename (d:\downloads\yarn-workspace\with-workspace\.pnp.js:9632:29)
    at Function.external_module_default.a._load (d:\downloads\yarn-workspace\with-workspace\.pnp.js:9534:50)
    at Module.require (internal/modules/cjs/loader.js:1028:19)
    at require (d:\downloads\yarn-workspace\global-store\cache\v8-compile-cache-npm-2.1.0-86ea69cdd0-1.zip\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at Object.<anonymous> (d:\downloads\yarn-workspace\with-workspace\.yarn\virtual\eslint-plugin-vue-virtual-7a58570315\2\global-store\cache\eslint-plugin-vue-npm-6.1.1-965a2de8e5-1.zip\node_modules\eslint-plugin-vue\lib\rules\no-unsupported-features.js:7:19)
    at Module._compile (d:\downloads\yarn-workspace\global-store\cache\v8-compile-cache-npm-2.1.0-86ea69cdd0-1.zip\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)

@zdm
Copy link
Author

zdm commented Dec 30, 2019

@arcanis Could you tell me, pls, how I can create folders and place files with Sherlock? I can't find any documentation.

@arcanis
Copy link
Member

arcanis commented Dec 30, 2019

It's a regular Node environment, so you can use all the fs methods: mkdir, writeFile, etc 🙂

Fwiw the error is right: eslint-plugin-vue is accessing the semver package, but it isn't defined in its dependencies.

@zdm
Copy link
Author

zdm commented Dec 30, 2019

But why this error is occured only when workspace is used?

@arcanis
Copy link
Member

arcanis commented Dec 30, 2019

Because in the "no workspaces" setup the top-level has a dependencies on semver. In order to make the transition easier Yarn implements a fallback where it will allow dependencies to access the top-level packages even if they aren't explicit dependencies (this is relatively safe to do because the top-level dependencies aren't affected by the dependency tree shape).

In fact, if you were to completely disable the fallback using pnpFallbackMode you would witness the same error on the "no workspaces" setup.

@zdm
Copy link
Author

zdm commented Dec 30, 2019

Seems, that I understood.
I need to treat workspace as top-level package and add missed dependencies there.
Thank you,

@arcanis
Copy link
Member

arcanis commented Dec 30, 2019

No, there is only a single top-level package, even if you use workspaces. The right fix is to use packageExtensions to explicitly tell Yarn that eslint-plugin-vue is missing a semver dependency, and open a PR on their repo to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
case study Package compatibility report
Projects
None yet
Development

No branches or pull requests

2 participants