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

Error building esy project when in a monorepo with a bucklescript frontend #193

Closed
mscharley opened this issue Nov 15, 2018 · 12 comments · Fixed by #440
Closed

Error building esy project when in a monorepo with a bucklescript frontend #193

mscharley opened this issue Nov 15, 2018 · 12 comments · Fixed by #440
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mscharley
Copy link

My project structure is as follows:

├── package.json (npm)
└── packages
    ├── backend
    │   └── package.json (esy)
    └── frontend
        └── package.json (npm)

I have a workspace setup in VSCode with three top-level folders, /, /packages/backend and /packages/frontend.

/node_modules/.lsp/debug.log

{"jsonrpc":"2.0","id":2,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///Users/matthewscharley/Code/smart-reason/packages/backend/src/Cohttp_server.re"}}}
[server] Got a method textDocument/codeLens
[server] processing took 0.00405311584473ms
Found a `dune` file at /Users/matthewscharley/Code/smart-reason/packages/backend/src
]] Making a new jbuilder package at /Users/matthewscharley/Code/smart-reason/packages/backend/src
=== Project root: /Users/matthewscharley/Code/smart-reason/packages/backend
Detected `esy` dependency manager for local use
Sending response {"id": 2, "jsonrpc": "2.0", "result": [{"range": {"start": {"line": 0, "character": 0}, "end": {"line": 0, "character": 0}}, "command": {"title": "Unable to load compilation data: Could not find local build dir", "command": ""}}]}

/packages/backend/node_modules/.lsp

Doesn't exist.

The log files look correct, but I'm noticing that there is an _esy folder that's popped up in the root of my project now. It could be that RLS isn't changing folder to the project root before executing the esy command.

The frontend project, which is BuckleScript + NPM works perfectly.

@mscharley
Copy link
Author

It's worth noting that if I open VS Code in the backend project only, it works correctly.

@mscharley
Copy link
Author

Oh, this is with version 1.3.0 of the VS Code extension.

@jaredly
Copy link
Owner

jaredly commented Nov 15, 2018

excellent :)

@jaredly jaredly closed this as completed Nov 15, 2018
@mscharley
Copy link
Author

mscharley commented Nov 15, 2018

Err. Did you mean to close this @jaredly ?

@jaredly
Copy link
Owner

jaredly commented Nov 16, 2018

oh wait, sorry! I somehow read "this is fixed with version 1.3.0"

@jaredly jaredly reopened this Nov 16, 2018
@mscharley
Copy link
Author

Oops! No, new issue with 1.3.0. 1.2.6 didn't even pick up my project correctly at all, so progress!

@jaredly jaredly added bug Something isn't working help wanted Extra attention is needed labels Nov 16, 2018
@jaredly jaredly changed the title Unable to detect esy project correctly when used with a VS Code workspace Error building esy project when in a monorepo with a bucklescript frontend Nov 16, 2018
@mscharley
Copy link
Author

Update for 1.4.0. Looks like the same issues are still around, it's just that there's now a different error message:

/node_modules/.lsp/debug.log

Read message
{"jsonrpc":"2.0","id":1,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///Users/matthewscharley/Code/smart-reason/packages/backend/src/AppServer.re"}}}
[server] Got a method textDocument/documentSymbol
[server] processing took 0.00691413879395ms
Found a `dune` file at /Users/matthewscharley/Code/smart-reason/packages/backend/src
]] Making a new jbuilder package at /Users/matthewscharley/Code/smart-reason/packages/backend/src
=== Project root: /Users/matthewscharley/Code/smart-reason/packages/backend
Detected `esy` dependency manager for local use
Sending response {"id": 1, "jsonrpc": "2.0", "error": {"code": -32603, "message": "Could not find local build dir"}}
Found a `dune` file at /Users/matthewscharley/Code/smart-reason/packages/backend/src
]] Making a new jbuilder package at /Users/matthewscharley/Code/smart-reason/packages/backend/src
=== Project root: /Users/matthewscharley/Code/smart-reason/packages/backend
Detected `esy` dependency manager for local use
Read message
{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/matthewscharley/Code/smart-reason/packages/backend/src/AppServer.re"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[]}}}
[server] Got a method textDocument/codeAction
[server] processing took 0.00715255737305ms
Found a `dune` file at /Users/matthewscharley/Code/smart-reason/packages/backend/src
]] Making a new jbuilder package at /Users/matthewscharley/Code/smart-reason/packages/backend/src
=== Project root: /Users/matthewscharley/Code/smart-reason/packages/backend
Detected `esy` dependency manager for local use
Sending response {"id": 2, "jsonrpc": "2.0", "error": {"code": -32603, "message": "Could not find local build dir"}}
Read message
{"jsonrpc":"2.0","id":3,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///Users/matthewscharley/Code/smart-reason/packages/backend/src/AppServer.re"}}}
[server] Got a method textDocument/codeLens
[server] processing took 0.00596046447754ms
Found a `dune` file at /Users/matthewscharley/Code/smart-reason/packages/backend/src
]] Making a new jbuilder package at /Users/matthewscharley/Code/smart-reason/packages/backend/src
=== Project root: /Users/matthewscharley/Code/smart-reason/packages/backend
Detected `esy` dependency manager for local use
Sending response {"id": 3, "jsonrpc": "2.0", "result": [{"range": {"start": {"line": 0, "character": 0}, "end": {"line": 0, "character": 0}}, "command": {"title": "Unable to load compilation data: Could not find local build dir", "command": ""}}]}

It looks like RLS is still creating a phantom /_esy folder too, instead of trying to run esy inside /packages/backend to use /packages/backend/_esy.

@nielmond
Copy link

nielmond commented Dec 4, 2018

I'm getting this too while playing around with this project https://github.com/anmonteiro/reason-graphql-fullstack which has a similar structure. @mscharley I couldn't even get it to work by opening VS Code in the backend folder (specifically this folder https://github.com/anmonteiro/reason-graphql-fullstack/tree/master/src/server) -- does that still work for you with 1.4.0? I couldn't get your symlink approach to work that you mentioned in #162 either.

@mscharley
Copy link
Author

The backend folder is working directly as of 1.4.0. The symlink is no longer necessary either, RLS picks up esy and dune and just works, the only issue I'm having is the apparently folder changing issue when the esy project isn't in the project root.

@anmonteiro
Copy link
Collaborator

@nielmond that project is actually a nice example where RLS works. However I don't think the way to get it working is documented yet. That would be a great first contribution if you'd like to do it.

Here's an explanation:

Basically reason-graphql-fullstack uses a named esy sandbox (@server, because the esy file is called server.json). Therefore, you need to open VSCode with esy @server code .. Everything should work nicely afterwards.

@nielmond
Copy link

@anmonteiro Thanks for the suggestion. Opening with esy @server code . did fix the "Cannot find local build dir" error; however, now there are new problems. In the console of VS Code is the error

File "command line", line 1:Error: Unbound module Pervasives

for both main.re and schema.re.

Looking in .lsp/debug.log on startup, it seemed to be going OK and then this happened:

>> Build system running: esy
>>> stdout

>>> stderr
info building [email protected]@d41d8cd9
error: build failed with exit code: 1
  build log:
    # esy-build-package: building: [email protected]
    # esy-build-package: pwd: ~/.esy/3________________________________________________________________/b/graphql__ppx-0.2.8-b650de8d
    # esy-build-package: running: 'dune' 'build' '@graphql_ppx'
    esy-build-package: unable to resolve command: dune
    
  building [email protected]
esy: exiting due to errors above
Affected files: 
Cleaning bsconfig.json

@Hossman333
Copy link

Hello! I know this is an old issue, but I solved the Unbound module Pervasives by cleaning the environment and re-installing everything.

You can clean it by running:

esy b dune clean

And then I just re-ran esy and reloaded VSCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants