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

Failed to refmt [doesn't work with a lerna monorepo] #217

Open
sample-usr opened this issue Dec 23, 2018 · 9 comments
Open

Failed to refmt [doesn't work with a lerna monorepo] #217

sample-usr opened this issue Dec 23, 2018 · 9 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sample-usr
Copy link

Hi, I'm having a problem regarding the language server. I have a lerna monorepo setup where the bsconfig.json is inside a sub project and the dependencies are hoisted at the parent level.

This is the error from node_modules/.lsp/debug.log

{"jsonrpc":"2.0","id":4,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/razagill/Development/nugen/shared/src/util/general.re"},"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":1}},"context":{"diagnostics":[]}}}
[server] Got a method textDocument/codeAction
[server] processing took 0.0321865081787ms
Sending response {"id": 4, "jsonrpc": "2.0", "error": {"code": -32603, "message": "Failed to refmt '/Users/razagill/Development/nugen/node_modules/bs-platform/lib/refmt.exe' --print binary --recoverable --parse re > '/Users/razagill/Development/nugen/shared/node_modules/.lsp/General-@nugen/shared.ast'\n/bin/sh: /Users/razagill/Development/nugen/shared/node_modules/.lsp/General-@nugen/shared.ast: No such file or directory"}}

version: 1.4.1
os: osx mojave 10.14.2
node: 11.0.0
bs-platform: 4.0.14

@jaredly
Copy link
Owner

jaredly commented Dec 28, 2018

oh interesting, I don't think I've tested with lerna monorepos before. I think yarn monorepos should work though. Would you be interested in helping add support for lerna?

@jaredly jaredly added enhancement New feature or request help wanted Extra attention is needed labels Dec 28, 2018
@sample-usr
Copy link
Author

@jaredly Absolutely. Although, I have no idea of how the language-server is working but I can help anyway I can.

@jaredly jaredly changed the title Failed to refmt Failed to refmt [doesn't work with a lerna monorepo] Jan 7, 2019
@jaredly
Copy link
Owner

jaredly commented Jan 7, 2019

@razagill could you make a pull-request that adds a simple lerna monorepo project to the examples/ directory, so I can test this out?

@nireno
Copy link

nireno commented Feb 3, 2019

I see a similar message in my project but I'm not working with lerna (so let me know if to open a new issue). I just have a bsconfig.json with the name @nireno/reasonably-typed. This causes a .lsp/<MyModuleName>-@nireno/reasonablyTyped.ast: Directory nonexistant error to show at the top of any .re file I open.

If I remove the / from the name in bsconfig the error goes away.

What's strange is that everything still seems to work. The code gets formatted properly on save and the project builds.

Side note: I had to spread my vscode across two screens to read that error :-)

@MoOx
Copy link
Contributor

MoOx commented Feb 7, 2019

Just got the same problem. It's not related to monorepo directly imo. As soon as I remove any / from the package name (in my case: @phenomic/*) it's ok. As soon as I add those back, I get an error on the path...

Eg:

'/Users/moox/Sync/Development/phenomic/node_modules/bs-platform/lib/refmt.exe' --print binary --recoverable --parse re > '/Users/moox/Sync/Development/phenomic/packages/data-server-wordpress/node_modules/.lsp/WordpressApiV2Posts-@phenomic/dataServerWordpress.ast'

FYI, currently ocaml?bucklescript? (I mean without this reason-language-server - by hand) handle those namespace as Just camel case (eg: @ns/something became NsSomething, so file like Else.re will ends up as Else-NsSomething.ast instead of Else-@ns/something.ast

@MoOx
Copy link
Contributor

MoOx commented Feb 7, 2019

To be clear what is triggering the issue is the conjunction of using npm scope in the name + bucklescript namespace feature.
Very easy to reproduce.

@MoOx
Copy link
Contributor

MoOx commented Feb 7, 2019

workaround

  • package.json/name: keep @ns/* (this one is used for npm)
  • bsconfig.json/name: ns-* (this one will end up with the same as @ns/ with normal reason tooling

@MoOx
Copy link
Contributor

MoOx commented Feb 7, 2019

In addition to refmt not working, if you have a package this way, linked (via npm or yarn) and used in another project, reason-language-server will crash 5 times & stop. I guess it's related, cause as soon as I used the workaround in my project that created linked package in the consumer project, everything started to work around (without any crash).

@tizoc
Copy link

tizoc commented Jun 10, 2019

Mine is a regular repo, and I'm getting this error often. I just created node_modules/.lsp manually and the error went away (for now at least).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants