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

Not working with Yarn Workspaces #317

Closed
thekevinbrown opened this issue Aug 11, 2020 · 10 comments
Closed

Not working with Yarn Workspaces #317

thekevinbrown opened this issue Aug 11, 2020 · 10 comments
Labels
question Further information is requested

Comments

@thekevinbrown
Copy link

I'm seeing #196 with "prettier-plugin-solidity": "1.0.0-alpha.55" We're using yarn workspaces.

I can't share the source at the moment. Anything I can do to debug?

$ prettier --write **/*.sol **/*.ts
[error] No parser could be inferred for file: contracts/Loggable.sol
...etc...
error Command failed with exit code 2.
@fvictorio
Copy link
Member

According to the docs:

Plugins are automatically loaded if you have them installed in the same node_modules directory where prettier is located.

So maybe the problem is that prettier is being hoisted but prettier-plugin-solidity it's not. Two things come to mind (but I don't know a lot about yarn workspaces):

  • Prettier has a --plugin-search-dir that you could use. I guess it would be something like --plugin-search-dir ../node_modules or maybe --plugin-search-dir packages/contracts/node_modules, I'm not sure.
  • Maybe you can configure yarn to avoid hoisting prettier, or force it to hoist prettier-plugin-solidity so that they are in the same node_modules?

@mattiaerre mattiaerre added the question Further information is requested label Aug 12, 2020
@thekevinbrown
Copy link
Author

Ah, this is kind of a pain. Is there a way to use two plugin search directories?

We're using buidler, which doesn't support having its deps hoisted, but also we're using prettier on all the packages, so we end up with two instances of prettier, one in our smart contracts package, and another hoisted one. We don't really want to install prettier-plugin-solidity in the workspace package json if we can avoid it, but I suppose we could have both if we have to.

@fvictorio
Copy link
Member

Just in case, buidler added support for workspaces in 1.4.5: NomicFoundation/hardhat#468 (comment) 🙂

@fvictorio
Copy link
Member

Also, again according to the docs:

Tip: You can set --plugin or --plugin-search-dir options multiple times.

@thekevinbrown
Copy link
Author

thekevinbrown commented Oct 8, 2020

It was indeed our smart-contracts buidler package that has hoisting disabled for this exact reason, so looks like the easiest thing to do there is just upgrade buidler, then turn off the hoisting.

@mattiaerre
Copy link
Member

it seems we can close this issue right @thekevinbrown ? thanks for your help @fvictorio

@thekevinbrown
Copy link
Author

Yup.

@chapati23
Copy link

Had the same problem when setting up a project with yarn v2. What worked for me was to set nodeLinker: "node-modules" in .yarnrc.yml: https://yarnpkg.com/configuration/yarnrc#nodeLinker

@JasoonS
Copy link

JasoonS commented Aug 10, 2022

Somewhat related, with pnpm I had to use the --plugin=prettier-plugin-solidity flag.

@Janther
Copy link
Contributor

Janther commented Aug 10, 2022

@JasoonS this appears to be an issue with prettier. prettier/prettier#9167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants