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

Detecting Elm's version fails #582

Open
welblaud opened this issue Dec 7, 2018 · 3 comments
Open

Detecting Elm's version fails #582

welblaud opened this issue Dec 7, 2018 · 3 comments

Comments

@welblaud
Copy link

welblaud commented Dec 7, 2018

I have just installed Elm and elm-format together via NPM. The problem is elm is in ma PATH and responds correctly (version 0.19) but elm-format logs:


I couldn't figure out what version of Elm you are using!

You should either run elm-format from the directory containing
your elm.json (for Elm 0.19) or elm-package.json (for Elm 0.18),
or tell me which version of Elm with --elm-version=0.19 or --elm-version=0.18

Where could be the problem?

  • Win 10 64bit
  • Tried call it both from CMD and Vim
  • Elm 0.19
@jwoudenberg
Copy link

I ran into a similar issue running elm-format through a Vim plugin, in monorepo project.

I usually start Vim in the root of the project, which is not the root of the Elm code. Vim takes elm-format from the path and tries to run it on an Elm module when I save, but because the cwd is the root of the project elm-format gives the error message above and nothing gets formatted.

I'm currently using a wrapper script around elm-format that ensures it is always ran with the --elm-version=0.19 parameter in this project. That works fine, but it's something I'll need to set up for each project with Elm code separately.

I think the error message we get is clear, but wonder if elm-format can recognize the correct version of Elm code in a wider variety of cases. For example: would it be an option to walk the directory tree upwards from the to-be-formatted file until an elm.json or elm-package.json file is encountered?

@avh4
Copy link
Owner

avh4 commented Dec 11, 2018

wonder if elm-format can recognize the correct version of Elm code in a wider variety of cases

See #561

@codefist
Copy link

codefist commented Jun 4, 2019

the easy and obvious fix here is to crawl UP the directory hierarchy until an elm.json file is found.
I shouldn't have to keep an elm.json file at the root of my project just make this work.
anyone opposed to that?! I'll take a swing at it unless someone else has a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants