jaredly / jaredly/reason-language-server

RLS Attempting to access nonexistant ~/.opam/4.07.0 folder

Open
#248 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
OCaml
Stars
649
Forks
85
PR merge metrics
No merged PRs in 30d

Description

While trying to open a very simple dune project, I get this error:
```
Setting log location: /Users/james.kraus/test-ocaml-program/node_modules/.lsp/debug.log
/bin/sh: /Users/james.kraus/.opam/4.07.0/bin/ocamlopt.opt: No such file or directory
/bin/sh: /Users/james.kraus/.opam/4.07.0/bin/ocamlopt.opt: No such file or directory
/bin/sh: /Users/james.kraus/.opam/4.07.0/bin/ocamlopt.opt: No such file or directory
[Error - 12:07:29 AM] Request textDocument/codeAction failed.
Message: Could not run compiler (ran /Users/james.kraus/.opam/4.07.0/bin/ocamlopt.opt -version). Output:
Code: -32603
```

Excerpt from the log file:
```
Read message
{"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":4}}
Read message
{"jsonrpc":"2.0","id":7,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/james.kraus/test-ocaml-program/sum.ml"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[]}}}
[server] Got a method textDocument/codeAction
[server] processing took 0.0360012054443ms
Found a `dune` file at /Users/james.kraus/test-ocaml-program
]] Making a new jbuilder package at /Users/james.kraus/test-ocaml-program
=== Project root: /Users/james.kraus/test-ocaml-program
Detected `opam` dependency manager for local use
=== Build dir: /Users/james.kraus/test-ocaml-program/_build
Get ocaml stdlib dirs
Include subdirs? no :/
Got a compiled base /Users/james.kraus/test-ocaml-program/_build/default/.sum.eobjs
Local file: /Users/james.kraus/test-ocaml-program/sum.ml
Local .cmt file: /Users/james.kraus/test-ocaml-program/_build/default/.sum.eobjs/Sum.cmt
>> Collecting deps for /Users/james.kraus/.opam/system/lib/stdio
>> Collecting deps for /Users/james.kraus/.opam/system/lib/sexplib0
>> Collecting deps for /Users/james.kraus/.opam/system/lib/base/shadow_stdlib
>> Collecting deps for /Users/james.kraus/.opam/system/lib/base/caml
>> Collecting deps for /Users/james.kraus/.opam/system/lib/base
>> Collecting deps for /Users/james.kraus/.opam/4.07.0/lib/ocaml
Depedency dirs /Users/james.kraus/.opam/system/lib/stdio /Users/james.kraus/.opam/system/lib/sexplib0 /Users/james.kraus/.opam/system/lib/base/shadow_stdlib /Users/james.kraus/.opam/system/lib/base/caml /Users/james.kraus/.opam/system/lib/base /Users/james.kraus/.opam/4.07.0/lib/ocaml
Sending response {"id": 7, "jsonrpc": "2.0", "error": {"code": -32603, "message": "Could not run compiler (ran /Users/james.kraus/.opam/4.07.0/bin/ocamlopt.opt -version). Output: "}}
```

I'm not sure why it's trying to access `/Users/james.kraus/.opam/4.07.0/bin/ocamlopt.opt` since `/Users/james.kraus/.opam/4.07.0` doesn't exist.

Anyone have any ideas?

Versions of stuff being used:
```bash
$ opam --version
2.0.3
$ ocaml --version
The OCaml toplevel, version 4.07.0
```

I'm using version 1.5.2 of RLS

Edit:

I'm guessing the directory is coming from these lines:
https://github.com/jaredly/reason-language-server/blob/af83153dc45c1beb315d66661ab9afc2b6babcd3/src/analyze/BuildSystem.re#L209-L214

Further debug info:
```bash
$ opam config env
OPAM_SWITCH_PREFIX='/Users/james.kraus/.opam/system'; export OPAM_SWITCH_PREFIX;
CAML_LD_LIBRARY_PATH='/Users/james.kraus/.opam/system/lib/stublibs:/usr/local/lib/ocaml/stublibs:/usr/local/lib/ocaml'; export CAML_LD_LIBRARY_PATH;
OCAML_TOPLEVEL_PATH='/Users/james.kraus/.opam/system/lib/toplevel'; export OCAML_TOPLEVEL_PATH;
PATH='...blah blah blah my path...'; export PATH;
```

```
$ opam config list

<><> Global opam variables ><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
arch x86_64 # Inferred from system
jobs 4 # The number of parallel jobs set up in opam configuration
make make # The 'make' command to use
opam-version 2.0.3 # The currently running opam version
os macos # Inferred from system
os-distribution homebrew # Inferred from system
os-family homebrew # Inferred from system
os-version 10.14.2 # Inferred from system
root /Users/james.kraus/.opam # The current opam root directory
switch system # The identifier of the current switch
sys-ocaml-version 4.07.0 # OCaml version present on your system independently of opam, if any

<><> Configuration variables from the current switch ><><><><><><><><><><><> 🐫
prefix /Users/james.kraus/.opam/system
lib /Users/james.kraus/.opam/system/lib
bin /Users/james.kraus/.opam/system/bin
sbin /Users/james.kraus/.opam/system/sbin
share /Users/james.kraus/.opam/system/share
doc /Users/james.kraus/.opam/system/doc
etc /Users/james.kraus/.opam/system/etc
man /Users/james.kraus/.opam/system/man
toplevel /Users/james.kraus/.opam/system/lib/toplevel
stublibs /Users/james.kraus/.opam/system/lib/stublibs
group group
user james.kraus
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at src/analyze/BuildSystem.re lines 209-214 and compare its path construction with the opam config env and config list shown in the report. Reproduce the codeAction failure with the system switch; done when the language server uses the existing ~/.opam/system compiler path rather than the nonexistent ~/.opam/4.07.0 path.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.