Quick Summary:
I have a project that expects a compiled elm.js in the root of the directory.
Running elm reactor on Windows 10 has different behavior than on OSX. On OSX, it runs the local web server, as expected. On Windows 10, it will instead try to directly open elm.js _unless no such file exists_, in which case it runs the local web server, as expected. If the elm.js file exists, no server is run - it just tries to open the file directly (which for my system defaults, just opens the file in an editor).
To get around this, I have to navigate up to a higher directory and run elm reactor.
Summary:
elm reactor starts the local web browserelm.js exists: Attempts to open the JS file.elm make --output=elm.js src/Whatever.elm
elm reactor
n/a
This implies that your Windows 10 command line has .js in its PathExt variable. When executing any command whatsoever, it will first check if a file in the current directory exists with an extension listed in PathExt, and execute that if found.
This is, in other words, nothing specific to Elm, and only happens due to the unfortunate combination of
elm from.To confirm my suspicion, could you verify the output of echo %pathext%?
Confirmed: I do have .js in my PATHEXT. I'm assuming my team member that first reported this does as well.
I am, however, a bit critical of this being "nothing specific to Elm"; as you say, it's partly caused specifically by having an elm.js file at the root. This seems like something that could use improvement; it doesn't seem to strictly be tool-independent.
I'm going to modify our project setup to not keep elm.js at the root, as this is disrupting our process. I appreciate the work that has been put into the tool and I hope to see it keep improving!
Regarding my "not specific to Elm" comment: because there is an elm.js file, and pathext has .js, the _command line_ chooses to try and execute this elm.js file when you run elm. The command does not even reach the actual elm executable, this is just a thing Windows does when you call an executable without specifying an extension.
Example:
If you were to add a file node.js and try to run node, you'd encounter the exact same issue. Same for any other executable.
So, I see four workarounds:
.js from PathExt (though presumably it was added for a reason)elm.js, but maybe bundle.js or main.jselm.cmd rather than elm (this should work when installed through npm, I'm not sure how this behaves when Elm was installed through the regular installer)elm.js file elsewhereI cannot think of any way in which Elm can prevent this situation.
I hope this helps!
Interesting. I previously did Windows system development for 7 years and have never encountered this before. I understand better now that it's not Elm-specific, thank you. :)
Thanks for figuring this one out @zwilias!
It sounds like there are not clear next steps for changing the elm binary in particular, so I will close this one.
Most helpful comment
Interesting. I previously did Windows system development for 7 years and have never encountered this before. I understand better now that it's not Elm-specific, thank you. :)