elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

elm-make creates spurious folder `C:\dev` with `--output /dev/null` on Windows #166

Open LukeWoodward opened 7 years ago

LukeWoodward commented 7 years ago

Sample run, starting with the directory not existing:

C:\Users\Luke\Elm>dir C:\dev\
The system cannot find the file specified.

C:\Users\Luke\Elm>elm-make --output /dev/null Zero.elm
Success! Compiled 1 module.
Successfully generated /dev/null

C:\Users\Luke\Elm>dir C:\dev\
 Volume in drive C is Windows7
 Volume Serial Number is F399-C363

 Directory of C:\dev

16/06/2017  21:57    <DIR>          .
16/06/2017  21:57    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  102,891,061,248 bytes free

For completeness, Zero.elm is

module Zero exposing (zero)
zero =
    0

but to be honest any valid Elm file will do.

The dev folder gets created on the user's current drive. In the above example C:\dev got created because my current drive was C:. However, no file with the name null gets created in this folder.

If you lack permission to create a folder in the root of your current drive, it is likely that elm-make will fail with a permission-denied error, which seems somewhat odd.

It seems the issue is with the generate function in src/Pipeline/Generate.hs. This function understands that the output file can be /dev/null, and doesn't write to a file in this situation, but it still attempts to create the parent directory of this file if it doesn't already exist. And on Windows there isn't always a folder named dev in the root of the current drive.

I'm using Elm 0.18 on Windows 10.

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

olisikh commented 6 years ago

Having the same issue, but in a different situation. When I run elm-test I get the output saying that elm-make can't create /dev directory (running elm-test from Git Bash).

elm-make-error-dev-folder