bsermons / flycheck-elm

Flycheck support for the elm language
GNU General Public License v3.0
18 stars 8 forks source link

Not working in subfolders #3

Closed bharrisau closed 8 years ago

bharrisau commented 8 years ago

Flycheck doesn't yet have a way to set the working directory for checkers, and in this case they need to run in the directory that has elm-package.json

Relevant issues flycheck/flycheck#312 flycheck/flycheck#754

My workaround at the moment is to set the default-directory in an elm-mode-hook.

BrianHicks commented 8 years ago

I'm running into this too, and it doesn't look like the flycheck issue is anywhere near being completed, ATM. How would you set default-directory? I'm not super familiar with how to do that for a project.

bsermons commented 8 years ago

Thanks for reporting the issue.

Here are a couple of ways that worked for me using @bharrisau workaround. The first uses a hook and the other by adding the code to a .dir-locals.el file in your project root.

Could you test that these work for you and I'll update the readme with this info if it works?

  (add-hook 'elm-mode-hook (lambda ()
                             (setq default-directory
                                   (locate-dominating-file default-directory "elm-package.json"))))
((elm-mode . ((eval . (progn
                        (setq default-directory
                              (locate-dominating-file default-directory "elm-package.json")))))))
BrianHicks commented 8 years ago

Looks like the first one works for me. Thanks!

bharrisau commented 8 years ago

Sorry, I should have posted an example solution. I'm doing the same as @bsermons first example except using an elm-mode function to find the correct directory.

(add-hook 'elm-mode-hook (lambda ()
    (setq default-directory (elm--find-dependency-file-path)))

Also need to make sure the elm-mode-hook is added after the hook that flycheck-elm adds, so that the directory is set before flycheck runs (hooks are run FILO).

mittenchops commented 8 years ago

I think I'm having some variation of this issue:

Flycheck mode enabled
Suspicious state from syntax checker elm: Checker elm returned non-zero exit code 1, but no errors from output: I cannot find find module 'Signals'.

Module 'Main' is trying to import it.

Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json

Checker definition probably flawed.
bsermons commented 8 years ago

What version of elm are you using? That looks like it is not sending the response back as json which the checker expects.

mittenchops commented 8 years ago

$ elm Elm Platform 0.16.0 - a way to run all Elm tools $ elm repl --version 0.16.0

bsermons commented 8 years ago

This seems like it might be a bug with elm-make when you have an unknown import. You can see if you try Ctrl-C ! Ctrl-C and selecting elm to compile the buffer with flycheck, then it does not send back json errors.

Not sure why but in my email I got this comment from Claudia Doppioslash but it does not show up here that might help: "That happens to me when I forget to install the package with elm-package install bla/blabla before trying to use it. You'll probably be aware of this, but C-u C-c M-k will open the elm-mode interface to elm-package, with works like package.el and is pretty handy."

doppioslash commented 8 years ago

That's because I deleted it. I thought "Signal" should be in core anyway, so it probably wasn't that. But I guess if you haven't installed core that may happen ^^;

So yeah, that happens to me when I forget to install the package with elm-package install bla/blabla before trying to use it. You'll probably be aware of this, but C-u C-c M-k will open the elm-mode interface to elm-package, with works like package.el and is pretty handy.

bsermons commented 8 years ago

Well I think the fix for him would be to import 'Signal' instead of 'Signals'.

mittenchops commented 8 years ago

I thought it was core too from the couple tutorials I tried and from here: http://package.elm-lang.org/packages/elm-lang/core/3.0.0/Signal.

Using Signal, with and without imports. Sorry, still total beginner in Elm trying to get linting up to get started. Was just following along on the readme with different results: is there something in the C-u C-c M-k I should install to get access to Signal so the browse inside the value will auto complete in a dropdown?

bsermons commented 8 years ago

Core should be installed when you init a new project. Flycheck is only used for syntax errors so it won't help with the dropdown completions.
Are you sure you are importing 'Signal' and not 'Signals' (pluralized)? Based on this error message it seems the latter:

Flycheck mode enabled
Suspicious state from syntax checker elm: Checker elm returned non-zero exit code 1, but no errors from output: I cannot find find module 'Signals'.

Module 'Main' is trying to import it.

If renaming doesn't work, can you run flycheck-compile (Ctrl-c ! Ctrl-c) and post the output to that?

purcell commented 8 years ago

There's a fix for this in https://github.com/bsermons/flycheck-elm/pull/10.