intellij-elm
intellij-elm copied to clipboard
Always treat `source-directories` as source roots, even if inside `elm-stuff`
This is very strange, as it worked the first time I opened the project, but not on subsequent tries.
We have a bunch of stuff under elm-stuff/gitdeps/[some-source-folder]
, and each of these are listed under "source-directories" in elm.json
. (We're using Skinney/elm-git-install
for private packages).
The first time I started IntelliJ and opened the Elm project, everything worked. The second time I started IntelliJ on the same project, all references to files in elm-stuff
gives a "undefined reference" error in the IDE.
My colleague figured out that if you run "invalidate cache" things start working again, while "synchronize" makes it fail. So, maybe this is a cache issue?
No idea if I'm explaining myself well, but I hope you have enough information to go on.
To get things to work again I have to delete the .idea folder and then "invalidate cache and restart"
The plugin marks elm-stuff
as an "Excluded" source root. This means that IntelliJ will ignore the contents. Normally this is what you want because there are a lot of intermediate files in there that the user (and the plugin) don't care about. But since your workflow stores .elm
files in there, you will need to override that.
In the Project View on the left-side, expand the elm-stuff
directory to locate the parent folder of your Elm files. Right-click it, choose "Mark directory as", then choose "Not Excluded".
Let me know the path of the directory that you end up excluding so that I can consider putting a hack in the plugin to avoid this situation for other users.
If you still can't get it to work, message me on Slack so that we can debug it further.
On a side note, I don't remember where Evan has said this before, but shouldn't 3rd party tools not be writing into the elm-stuff
directory?
After thinking about this a little bit more, this is a bug. The plugin should honor the source-directories
listed in your elm.json
. I will figure out a way to register them as src-roots, even if they are contained within an excluded folder. No need for a special-case for elm-git-install
.
Thanks for bringing this to my attention 😄
Hi. Cool! And thanks for providing us with a work-around.
I remember Evan saying this at some point too, but i wonder if that was pre-0.19 days? The compiler only uses elm-stuff/0.19.0
, so elm-stuff/gitdeps/*
seemed safe (and it was a folder likely to be gitignore already, making my tool "just work". Of course, one shouldn't mess around with the files inside elm-stuff/0.19.0/*
In the Project View on the left-side, expand the
elm-stuff
directory to locate the parent folder of your Elm files. Right-click it, choose "Mark directory as", then choose "Not Excluded".
I've run into this issue as well when using elm-git-install but this solution doesn't seem to work for me. Functions calls and imports of the github elm package are marked in red with an "Unresolved referernce module_name" error.
Edit: I tried restarting intellij in case it was a caching issue but that didn't have any effect.
Very late followup, I ran into this same issue again but I realized this time that what I had done was mark a subdirectory in elm-stuff as a "sources root". That doesn't work. Marking all of elm-stuff as "not excluded" works.
It looks like this still isn't a solution due to my "not excluded" changes getting ignored when I restart intelliJ (even though the changes are still present in my .iml file). I also tried removing <excludePattern pattern="elm-stuff" />
and replacing it with <excludePattern pattern="0.19.1" />
but this also stops working if I restart intelliJ. In order to fix it I have to remove the excludePattern, save the .iml file, and then add it back.