jaredly / jaredly/reason-language-server

Can't find *.objs folder when buildsInSource option is enabled in esy

Open
#209 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
649
Forks
85
PR merge metrics
No merged PRs in 30d

Description

I am not 100% sure it's because of `"buildsInSource": "_build"` option in esy, but in `reason-reactify`, where that option [is enabled](https://github.com/bryphe/reason-reactify/blob/master/package.json#L13), RLS doesn't seem to be able to find the object files.

It seems to be looking in `_esy/default/...` but the `.objs` folder is in `_build/default/...`:

```
Unix.Unix_error(Unix.ENOENT, "opendir", "/Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/../../lib/.reactify.objs")
```

The debug log doesn't seem to include any relevant info (it crashes as soon as an `.re` file is opened) but here it is fwiw:

debug.log

```
Hello from /Users/javi/.vscode/extensions/jaredly.reason-vscode-1.4.0/bin.native
Previous log location: /var/folders/ss/97gmv_jn031f29dsvb600f280000gn/T/lsp.log
Sending notification {"jsonrpc": "2.0", "method": "client/registerCapability", "params": {"registrations": [{"id": "watching", "method": "workspace/didChangeWatchedFiles", "registerOptions": {"watchers": [{"globPattern": "**/bsconfig.json", "globPattern": "**/.merlin"}]}}]}}
Sending response {"id": 0, "jsonrpc": "2.0", "result": {"capabilities": {"textDocumentSync": 1, "hoverProvider": true, "completionProvider": {"resolveProvider": true, "triggerCharacters": ["."]}, "signatureHelpProvider": {"triggerCharacters": ["("]}, "definitionProvider": true, "typeDefinitionProvider": true, "referencesProvider": true, "documentSymbolProvider": true, "codeActionProvider": true, "executeCommandProvider": {"commands": ["reason-language-server.add_to_interface_inner"]}, "codeLensProvider": {"resolveProvider": true}, "documentHighlightProvider": true, "documentRangeFormattingProvider": true, "documentFormattingProvider": true, "documentFormattingProvider": true, "renameProvider": true}}}
Read message
{"jsonrpc":"2.0","method":"initialized","params":{}}
Read message
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"reason_language_server":{"location":"","refmt":"","lispRefmt":"","format_width":"80","per_value_codelens":false,"dependencies_codelens":true,"opens_codelens":true,"show_module_path_on_hover":true,"reloadOnChange":false,"show_debug_errors":false,"autoRebuild":true}}}}
Read message
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/javi/Development/github/reason-reactify/examples/dom/WebReconciler.re","languageId":"reason","version":1,"text":"/**\n * This is an implementation of a reconciler for DOM elements via js_of_ocaml :\n * http://ocsigen.org/js_of_ocaml/3.1.0/api/Dom_html\n *\n * This is just an example but you could use this to create interesting\n * CLI apps, with a react-like functional API!\n*/\nmodule Reconciler = {\n /*\n Step 1: Define primitives\n */\n type imageProps = {src: string};\n type buttonProps = {src: string};\n type primitives =\n | Div\n | Span(string)\n | Image(imageProps);\n\n /*\n Step 2: Define node type\n */\n type node =\n | Div(Js.t(Dom_html.divElement))\n | Span(Js.t(Dom_html.element))\n | Image(Js.t(Dom_html.imageElement))\n | Container(Js.t(Dom_html.element));\n let document = Dom_html.window##.document;\n\n /*\n Step 3: Implement a create function\n */\n let createInstance: primitives => node =\n primitive =>\n switch (primitive) {\n | Div => Div(Dom_html.createDiv(document))\n | Span(s) =>\n let e = Dom_html.createSpan(document);\n e##.innerHTML := Js.string(s);\n Span(e);\n | Image(p) =>\n let img = Dom_html.createImg(document);\n img##.src := Js.string(p.src);\n Image(img);\n };\n\n /*\n Step 4: Implement remaining primitives\n */\n\n let _getInnerNode = node =>\n switch (node) {\n | Div(e) => e |> Dom_html.element\n | Span(e) => e |> Dom_html.element\n | Image(e) => e |> Dom_html.element\n | Container(e) => e |> Dom_html.element\n };\n\n let updateInstance =\n (node: node, _oldPrimitive: primitives, newPrimitive: primitives) =>\n switch (newPrimitive, node) {\n /* The only update operation we handle today is updating src for an image! */\n | (Image({src}), Image(e)) => e##.src := Js.string(src)\n | _ => ()\n };\n\n let appendChild = (parentNode: node, childNode: node) => {\n let innerNode = _getInnerNode(childNode);\n switch (parentNode) {\n | Div(e) => Dom.appendChild(e, innerNode)\n | Span(e) => Dom.appendChild(e, innerNode)\n | Image(e) => Dom.appendChild(e, innerNode)\n | Container(e) => Dom.appendChild(e, innerNode)\n };\n };\n\n let removeChild = (parentNode: node, childNode: node) => {\n let innerNode = _getInnerNode(childNode);\n switch (parentNode) {\n | Div(e) => Dom.removeChild(e, innerNode)\n | Span(e) => Dom.removeChild(e, innerNode)\n | Image(e) => Dom.removeChild(e, innerNode)\n | Container(e) => Dom.removeChild(e, innerNode)\n };\n };\n\n let replaceChild = (parentNode: node, oldChild: node, newChild: node) => {\n let newInnerNode = _getInnerNode(newChild);\n let oldInnerNode = _getInnerNode(oldChild);\n switch (parentNode) {\n | Div(e) => Dom.replaceChild(e, newInnerNode, oldInnerNode)\n | Span(e) => Dom.replaceChild(e, newInnerNode, oldInnerNode)\n | Image(e) => Dom.replaceChild(e, newInnerNode, oldInnerNode)\n | Container(e) => Dom.replaceChild(e, newInnerNode, oldInnerNode)\n };\n };\n};\n\n/* Step 5: Hook it up! */\nmodule JsooReact = Reactify.Make(Reconciler);\n\n/* Define our primitive components */\nlet div = (~children, ()) => JsooReact.primitiveComponent(Div, ~children);\n\nlet span = (~text, ~children, ()) =>\n JsooReact.primitiveComponent(Span(text), ~children);\n\nlet image = (~children, ~src, ()) =>\n JsooReact.primitiveComponent(Image(src), ~children);\n\n/* Create a container for our UI */\nlet container =\n JsooReact.createContainer(\n Reconciler.Container(Dom_html.getElementById_exn(\"app\")),\n );\n\n/* Let's finally put our UI to use! */\nlet render = () =>\n ;\n\n/* First render! */\nJsooReact.updateContainer(container, render());"}}}
Found a `dune` file at /Users/javi/Development/github/reason-reactify/examples/dom
]] Making a new jbuilder package at /Users/javi/Development/github/reason-reactify/examples/dom
=== Project root: /Users/javi/Development/github/reason-reactify
Detected `esy` dependency manager for local use
=== Build dir: /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0
Get ocaml stdlib dirs
Include subdirs? no :/
Got a compiled base /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/.WebReconciler.eobjs
Local file: /Users/javi/Development/github/reason-reactify/examples/dom/WebReconciler.re
Local .cmt file: /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/.WebReconciler.eobjs/WebReconciler.cmt
Other directory: /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/../../lib/.reactify.objs
Sending notification {"jsonrpc": "2.0", "method": "window/showMessage", "params": {"type": 1, "message": "Unix.Unix_error(Unix.ENOENT, \"opendir\", \"/Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/../../lib/.reactify.objs\")Raised by primitive operation at file \"util/Files.re\", line 185, characters 7-24\nCalled from file \"src/analyze/FindFiles.re\", line 154, characters 17-47\nCalled from file \"src/analyze/State.re\", line 381, characters 24-253\nCalled from file \"_none_\", line 0, characters 254-1023\nCalled from file \"util/Infix.re\", line 7, characters 110-120\nCalled from file \"list.ml\", line 117, characters 24-34\nCalled from file \"src/analyze/State.re\", line 366, characters 39-1023\nCalled from file \"src/analyze/State.re\", line 538, characters 24-75\nCalled from file \"src/lsp/NotificationHandlers.re\", line 75, characters 24-72\nCalled from file \"src/lsp/BasicServer.re\", line 84, characters 11-35\n"}}
Read message
{"jsonrpc":"2.0","id":1,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/javi/Development/github/reason-reactify/examples/dom/WebReconciler.re"},"range":{"start":{"line":117,"character":23},"end":{"line":117,"character":23}},"context":{"diagnostics":[]}}}
[server] Got a method textDocument/codeAction
[server] processing took 0.00596046447754ms
Found a `dune` file at /Users/javi/Development/github/reason-reactify/examples/dom
]] Making a new jbuilder package at /Users/javi/Development/github/reason-reactify/examples/dom
=== Project root: /Users/javi/Development/github/reason-reactify
Detected `esy` dependency manager for local use
=== Build dir: /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0
Get ocaml stdlib dirs
Include subdirs? no :/
Got a compiled base /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/.WebReconciler.eobjs
Local file: /Users/javi/Development/github/reason-reactify/examples/dom/WebReconciler.re
Local .cmt file: /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/.WebReconciler.eobjs/WebReconciler.cmt
Other directory: /Users/javi/Development/github/reason-reactify/_esy/default/store/b/reason_reactify-967a3fa0/default/examples/dom/../../lib/.reactify.objs
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The failure path is shown in util/Files.re, src/analyze/FindFiles.re, and src/analyze/State.re; start by tracing how the esy build directory is selected for buildsInSource. Done means the existing .reactify.objs location is found without the ENOENT shown when opening examples/dom/WebReconciler.re.

Written by the indexing model from the issue text.

Assessment

Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.