Berry: [Bug] @yarnpkg/pnpify: VSCode fail to start the language server

Created on 16 Dec 2019  路  2Comments  路  Source: yarnpkg/berry

  • [x] I'd be willing to implement a fix

Describe the bug

In a monorepo, if @yarnpkg/pnpify is added to a package.json at the workspace level, but not at the root level, the language server crashes when VSCode starts it.

To Reproduce

I'm not sure how to write a Sherlock repro in this situation as it involves VSCode, and I'm unfamiliar with how to debug a language server.

Here is a screencast to show the repo steps and illustrate the error:

Environment if relevant (please complete the following information):

  • OS: Mac OS X Catalina
  • Node version: 10.17.0
  • Yarn version: 2.0.0-rc.19

    • @yarnpkg/pnpify:2.0.0-rc.12`

Additional context

I suppose it makes sense for pnpify to be installed at the root. If you think it should be the case, then perhaps it would be nice to enforce it or mention it in the docs here: https://next.yarnpkg.com/advanced/pnpify#vscode-support.

bug good first issue

Most helpful comment

I think the problem comes from here:

https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-pnpify/sources/generateSdk.ts#L17

Since we access @yarnpkg/pnpify through its bare identifier, it needs to be at the root. I guess we could use a relative path, but I think it makes more sense to require the sdk to be installed at the root regardless - which means that the correct fix is to simply throw a UsageError in generateSdk if --sdk is used by a non-root package!

All 2 comments

I think the problem comes from here:

https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-pnpify/sources/generateSdk.ts#L17

Since we access @yarnpkg/pnpify through its bare identifier, it needs to be at the root. I guess we could use a relative path, but I think it makes more sense to require the sdk to be installed at the root regardless - which means that the correct fix is to simply throw a UsageError in generateSdk if --sdk is used by a non-root package!

Closing since the TS sdk doesn't use pnpify anymore

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kiprasmel picture kiprasmel  路  3Comments

wojtekmaj picture wojtekmaj  路  3Comments

bradleyayers picture bradleyayers  路  3Comments

juanpicado picture juanpicado  路  4Comments

Mike-Dax picture Mike-Dax  路  3Comments