microsoft / typespec

https://typespec.io/
MIT License
4.51k stars 217 forks source link

[Bug]: Unable to run the tsp command in a monorepo (yarn workspaces) #4509

Closed cincauhangus closed 1 month ago

cincauhangus commented 1 month ago

Describe the bug

I'm currently trying to migrate a standalone typespec package into a monorepo and I'm having troubles trying to run yarn tsp compile after installation.

Note: This error does not appear when running as a standalone package.

Errors when running tsp compile . image

Issue stems from this library file in the @typespec/openapi3 package: image

Reproduction

  1. Create a simple monorepo (using yarn)
  2. Create a child repo and install typespec
  3. Run tsp compile . in the new repo.

Checklist

timotheeguerin commented 1 month ago

Hey I tried to reproduce this issue in a basic yarn 4.5.0 workspace and couldn't could you make a basic repo where this reproduce? And can you share which version of yarn + what options you are using?

jpx15 commented 1 month ago

I've encountered this error with npm workspaces as well.

cincauhangus commented 1 month ago

Hey I tried to reproduce this issue in a basic yarn 4.5.0 workspace and couldn't could you make a basic repo where this reproduce? And can you share which version of yarn + what options you are using?

Apologies @timotheeguerin - I am running on yarn 3.5.x, node 20.11.0, Windows 11

Repo: https://github.com/cincauhangus/issue-typespec-4509

When running on typespec v0.60.x: image

When running on typespec v0.54.x: image

timotheeguerin commented 1 month ago

Thanks for the repro, i do get the error now as well with 0.60.0, for the 0.54, I'll assume that that part was fixed or the error is just showing in a different way.

What is intresting is it only seems to affect finding the emitter

timotheeguerin commented 1 month ago

ok so I found the issue, the problem is that openapi3 library request a dependency on @typespec/openapi and @typespec/versioning but those were not installed.

If you add this to your package.json it works

    "@typespec/openapi": "^0.60.0",
    "@typespec/versioning": "^0.60.0"

what I don't really get is why yarn just silently ignore those not being present

Edit: nvm it does image

timotheeguerin commented 1 month ago

Unfortunately it doesn't looks like yarn can install those automatically

jpx15 commented 1 month ago

ok so I found the issue, the problem is that openapi3 library request a dependency on @typespec/openapi and @typespec/versioning but those were not installed.

If you add this to your package.json it works

    "@typespec/openapi": "^0.60.0",
    "@typespec/versioning": "^0.60.0"

what I don't really get is why yarn just silently ignore those not being present

Edit: nvm it does image

Installing both of these fixed the issue, thank you!

cincauhangus commented 1 month ago

ok so I found the issue, the problem is that openapi3 library request a dependency on @typespec/openapi and @typespec/versioning but those were not installed.

If you add this to your package.json it works

    "@typespec/openapi": "^0.60.0",
    "@typespec/versioning": "^0.60.0"

what I don't really get is why yarn just silently ignore those not being present

Edit: nvm it does image

Can confirm that fixed the issue in both v0.54 and v0.60. Thanks for the support!

Do you want to keep this issue open, @timotheeguerin ?

timotheeguerin commented 1 month ago

Yeah, i think there is a few takeaway. Need docs for yarn, better error in that case that shows the root error. Find way to validate peer deps are actually installed.

markcowl commented 1 month ago