Compiler: elm reactor has different behavior on Windows 10 (Elm 0.19)

Created on 23 Apr 2019  路  5Comments  路  Source: elm/compiler

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:

  • OSX: elm reactor starts the local web browser
  • Windows 10:

    • If elm.js exists: Attempts to open the JS file.

    • Else: starts the local web browser

SSCCE

elm make --output=elm.js src/Whatever.elm
elm reactor
  • Elm: 0.19
  • Browser: Chrome (but this behavior happens before it touches any browsers)
  • Operating System: Windows 10

Additional Details

n/a

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. :)

All 5 comments

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

  • .js listed in PathExt on your environment
  • an elm.js file existing in the directory you want to run 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:

  • remove .js from PathExt (though presumably it was added for a reason)
  • don't name the file elm.js, but maybe bundle.js or main.js
  • call elm.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)
  • move the elm.js file elsewhere

I 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

torepettersen picture torepettersen  路  4Comments

SidneyNemzer picture SidneyNemzer  路  4Comments

ShalokShalom picture ShalokShalom  路  3Comments

robinheghan picture robinheghan  路  3Comments

kuon picture kuon  路  3Comments