When creating projects with elm init, elm creates a project structure where there is a elm.json in the root of the project directory and a src folder, where your .elm files should go

Elm-mode for emacs doesn't seem to support this. When visiting a file in the src directory and typing C-c C-c to compile the file, I get the following error:

-*- mode: elm-compilation; default-directory: "~/Projects/select-elm/src/" -*-
Elm-Compile started at Mon May 13 04:29:55

/home/chris/.nvm/versions/node/v8.9.3/bin/elm make Main.elm --output\=elm.js
-- FILE NOT FOUND --------------------------------------------------------------

You want me to compile this file:


I cannot find it though! Is there a typo?

Elm-Compile exited abnormally with code 1 at Mon May 13 04:29:56

This is the same error you get when calling elm make Main.elm from the command line in the src folder instead of in the root folder of the project.

If this same file is saved to the root folder of the project, C-c C-c compiles the file without errors. It seems elm-mode expects source files to be directly in the root directory of a project, while the elm language convention is to save the source files in the src folder.

I'm using elm 0.19.0. Is there a graceful way to make elm-mode "project aware", or something similar?

Unfortunately I don't have the option of simply saving my files to the root folder of the project because this is not a project that I own.

  • Are you calling the right compile function? By default, C-c C-c is bound to elm-compile-buffer, which basically runs elm make <filename of current buffer> in the current directory. C-c M-c is bound to elm-compile-main which will basically run elm make Main.elm in the current directory, even if Main.elm isn't there.
    – nega
    May 13, 2019 at 17:48
  • If that's not the case, your project style just might not jive with elm-mode. You can see what elm-mode settings you can customize (M-x customize-mode RET elm), or you can file an issue with the elm-mode developers. Be explicit with how your project is set up, and help you with customization, or add the features you need.
    – nega
    May 13, 2019 at 17:52
  • C-c M-c warns me "Elm package file not found. Create a new package file? (yes or no)". When I answer "yes", the command fails with "Opening input file: No such file or directory, ~/Projects/select-elm/src/elm-package.json". Re-running C-c M-c and answering "no" doesn't produce anything useful either.
    – flooose
    May 13, 2019 at 20:25
  • As far as my "project style" goes, it's actually that of elm, i.e. what elm init created, which is why I'm confused; elm and elm-mode seem to have divergent notions of their project structure. Looking at the sources, I also saw that elm-mode does a lot with default-directory, which when you're visiting a file is the directory the file resides in. This is why I mentioned "project aware" above. I'm still debugging though and will report back.
    – flooose
    May 13, 2019 at 20:32

1 Answer 1


It took me a while to figure this one out, posting to help future users.

Elm-mode uses by default "elm-package.json" to find the root directory of your project. This was the value used in Elm 0.18 and changed in 0.19 to "elm.json".

Just customize the variable elm-package-json and set it to "elm.json".

For example (setq elm-package-json "elm.json")

This is described in elm-util.el

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.