reasonml / ReasonNativeProject

Reason native compilation starter project
MIT License
203 stars 45 forks source link

Unable to ocamlmerlin error on Atom #1

Closed vramana closed 7 years ago

vramana commented 7 years ago

When I run npm run whereisocamlmerlin, which is successfully locating ocamlmerlin

# vramana at pc in ~/Documents/reasonml/ExampleProject on git:master ✖︎ [15:10:12]
→ npm run whereisocamlmerlin 

> ExampleProject@0.0.1 whereisocamlmerlin /home/vramana/Documents/reasonml/ExampleProject
> eval $(dependencyEnv) && which ocamlmerlin-reason

/home/vramana/Documents/reasonml/ExampleProject/node_modules/reason/_build/ocamlfind/bin/ocamlmerlin-reason

But when I run npm run editor, I get the error image

cc @jordwalke

jordwalke commented 7 years ago

Ah, did you update to the latest atom-reason-loader? Did you restart? Could you let me know which version of atom-reason-loader you have, just to double check that you got our latest stuff.

vramana commented 7 years ago

I think so. I am using atom-reason-loader@0.5.0

jordwalke commented 7 years ago

Oh, I think I know what might be happening. You already have an Atom editor window open so it uses an old PATH?

jordwalke commented 7 years ago

Hmm, that's probably not it actually. I just tried running npm run editor when I already had an Atom window open and it worked. (Good news is that workflow worked for me! Meaning npm run editor is probably not a bad workflow in the general case) Still have to figure out what your issue is though.

jordwalke commented 7 years ago

Maybe it's an issue with Linux paths? (Cheng Lou said it was working for him on Mac, and it works for me on Mac).

vramana commented 7 years ago

Oh, I think I know what might be happening. You already have an Atom editor window open so it uses an old PATH?

No. Reopened my terminal and checked again.

Maybe it's an issue with Linux paths? (Cheng Lou said it was working for him on Mac, and it works for me on Mac).

Possible. Any ideas on how I can debug this?

jordwalke commented 7 years ago

In the console in Atom, I believe you can type things like:

process.env.PATH

To see the path.

And

require('child_process').execSync('which ocamlmerlin').toString()

To run commands inside the editor with its environment.

vramana commented 7 years ago
process.env.PATH.split(':')

/home/vramana/Documents/reasonml/ExampleProject/node_modules/camomile/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/zed/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/react/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/ppx_tools/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/conf-ncurses/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/camlp4/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/base-no-ppx/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/lwt/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/lambda-term/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/utop/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/merlin-extend/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/cppo/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/conf-which/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/biniou/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/yojson/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/merlin/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/menhir/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/easy-format/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/ounit/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/base-bytes/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/re/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/opam-installer-bin/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/conf-m4/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/ocamlfind/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/ocaml/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/ANSITerminal/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/BetterErrors/_build/ocamlfind/bin
/home/vramana/Documents/reasonml/ExampleProject/node_modules/reason/_build/ocamlfind/bin

// ... some unrelated paths
require('child_process').execSync('which ocamlmerlin').toString()
"/home/vramana/Documents/reasonml/ExampleProject/node_modules/merlin/_build/ocamlfind/bin/ocamlmerlin
"

This seems wierd.

jordwalke commented 7 years ago

Could you also try commenting out the line in your .bashrc where you load the opam paths? Maybe it's confusing things - the fact that your paths include opam and npm locations?

vramana commented 7 years ago

I have removed that already. This is the full list of paths.

PATH home/vramana/Documents/reasonml/ExampleProject/node_modules/camomile/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/zed/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/react/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/ppx_tools/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/conf-ncurses/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/camlp4/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/base-no-ppx/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/lwt/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/lambda-term/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/utop/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/merlin-extend/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/cppo/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/conf-which/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/biniou/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/yojson/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/merlin/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/menhir/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/easy-format/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/ounit/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/base-bytes/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/re/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/opam-installer-bin/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/conf-m4/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/ocamlfind/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/ocaml/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/ANSITerminal/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/BetterErrors/_build/ocamlfind/bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/reason/_build/ocamlfind/bin /home/vramana/.nvm/versions/node/v6.4.0/lib/node_modules/npm/bin/node-gyp-bin /home/vramana/Documents/reasonml/ExampleProject/node_modules/.bin /home/vramana/.nvm/versions/node/v6.4.0/bin /home/vramana/.nvm/versions/node/v6.4.0/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /home/vramana/Documents/chromium/tools/depot_tools /home/vramana/Downloads/android-studio/bin /home/vramana/Android/Sdk/platform-tools /home/vramana/Downloads/genymotion /home/vramana/.cargo/bin /home/vramana/.local/bin/"
jordwalke commented 7 years ago

Thanks for testing this stuff.

I'll take a look tomorrow - it would be good if you can find another Linux user who could repro. I'm on the latest Atom beta btw. Not sure if that matters.

vramana commented 7 years ago

Even I am on atom-beta. I don't where I can another Linux user. I'll try running ubuntu without opam on Virtualbox.

jordwalke commented 7 years ago

You could ask in gitter, too.

vramana commented 7 years ago

I have completely removed opam and even then atom still gives the same error.

I tried to see if vim works. Vim takes a really long time to open (7 secs or so). Then when I try to ReasonPrettyPrint. I get the following error

image

jordwalke commented 7 years ago

Ah! One thing that might not be helping: what's the .merlin have for S sources? Is it the node modules directory? Try removing that. That has so many files to search through it tanks Merlin. I like your approach of getting it to work in Vim first. Also you saw the updated instructions for vim?

vramana commented 7 years ago

@jordwalke Yes. I saw them and updated my vimrc.

Removing node_modules brings things back to normal speed. No more autocomplete though 😦 .

Also that error comes when saving the file not when I run ReasonPrettyPrint. ReasonPrettyPrint works totally fine.

jordwalke commented 7 years ago

I bet this has something to do with paths (something working on mac, but not linux). So we should do to ocamlmerlin whatever we're doing for reason to augment the path (where refmt comes from).

vramana commented 7 years ago

Closing issues this since it's fixed in the atom-reason plugin long back. I don't know the status of vim error though. Will file a different issue for it.