elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.54k stars 664 forks source link

[Windows]'Access violation in generated code' when running any elm command #1797

Open Worble opened 6 years ago

Worble commented 6 years ago

Hi there, after upgrading to elm 0.19, attempting to do elm init causes this error message:

Hello! Elm projects always start with an elm.json file. I can create them!
...<snip for brevity>...
Knowing all that, would you like me to create an elm.json file now? [Y/n]: y
Access violation in generated code when reading 000000000f841bb4

I can ignore this and continue with ‘n’, opting to make the elm.json myself, except that elm make gives the same error and code when trying to run it on Main.elm with any valid elm contents (for example, copy and pasting the code from https://guide.elm-lang.org/). elm repl gives the same error when trying to run any code as well.

I was originally using elm 0.18 installed using npm, so I uninstalled that and reinstalled 0.19 with the windows installer to make sure it wasn’t causing any issues and the error still persists.

I am using Windows 10 version 1703, OS build 15063.1266. This is a work machine behind a corporate proxy, and I can confirm a colleague who previously had no version of elm installed also has the same issues as I do.

soelinn commented 6 years ago

I can also confirm that Elm 0.19 elm init results in the following error. OS: Windows 10 version 1803 (OS Build 17134.285)

Access violation in generated code when reading 000000000f841bb6

On my MacBook, it works fine. I'd be glad to help post some other info if needs be. Thank you for the great work Elm team. Loving the simplicity of Elm. Elm newbie here.

bbecker-inlogik commented 6 years ago

I can also confirm that installer for windows 0.19.0 results in above error. I had to use Windows Subsystem Linux with Ubuntu on to install Elm 0.19.0.

phm200 commented 6 years ago

Same issue for me. I had Elm 0.18 for windows installed and working fine. Then uninstalled everything and started from a clean slate with Elm 0.19 for windows. Any command in the repl gives me the access violation error. Happy to provide system details to help troubleshoot this. So interested to learn more Elm and stopped in my tracks for now

phm200 commented 6 years ago

Update: Elm REPL and elm init work fine for me if I run the commands from a regular (not elevated) command prompt. It is only when I run from an Admin command prompt that I get the access violation. I tend to run from an Admin command prompt to make life easier for the other languages and frameworks I use. Given that the Elm installer asks for elevated privileges, I assumed elm itself would work under elevated privileges. I guess not. Curious if this fixes the issues for @soelinn @Worble or @bbecker-inlogik

Worble commented 6 years ago

@phmiller Unfortunately, this issue still occurs for me regardless of elevated command prompt or not, tested on both cmd and powershell. @bbecker-inlogik Do your elm commands work on WSL? I was able to install it, however the commands are not only very slow, but still also error out (and once also bluescreened windows for me)

bbecker-inlogik commented 6 years ago

Thanks @phmiller. It does work for me from windows command prompt non-admin.

@Worble, I had a freshly installed Ubuntu LTS on WSL, did apt-get update and then installed elm and latest nodejs to get it working. You might try updating your node to latest?

Worble commented 6 years ago

@bbecker-inlogik Ah, I didn't think about updating node. It now works on WSL, although it is still rather slow. Thanks!

Kurren123 commented 6 years ago

Same here, get the error with elm init and elm make. Access violation in generated code when reading 000000000f841bb4

OS: Windows 10

StoatPower commented 6 years ago

I'm also experiencing this issue as of 0.19 when running from an admin terminal, and can confirm that it does work when running from a non-elevated terminal.

Kurren123 commented 6 years ago

I completely wiped my PC and started from scratch, installing windows 10 and elm. This fixed the issue so clearly something else was getting in the way.

Kurren123 commented 6 years ago

Update: Installed docker, visual studio 2017 and enabled IIS and BAM: Access violation in generated code when reading 000000000f841bb4

Kurren123 commented 6 years ago

This is occurring on my home pc, work pc and build server. I'm wondering if it's a haskell compiler issue.

Kurren123 commented 6 years ago

Recompiled with GHC 8.4 by upgrading language-glsl to >= 0.0.2 && < 0.4. Get the same error.

Kurren123 commented 6 years ago

I think it's a ghc error. I run

stack init
stack build
stack ghci

And I get Access violation in generated code when reading 0000000004b5b91e. It's a shame because this seems like a fairly common error and I'm guessing it's affected other people on windows who are running other haskell apps.

Kurren123 commented 6 years ago

Alright so it certainly looks like a GHC problem. As a workaround, I rebuilt the elm compiler using GHC 8.0.1, making a few necessary code changes for the old GHC to work, and low and behold no more access violation issues!

For everyone in this thread and anyone in the future reading this, you can download the patched version here.

@Worble you can close the thread if you'd like, as it's an upstream issue.

Tvde1 commented 5 years ago

Just installed elm today and having the same issue. Is it not been patched in the official installer?

Kurren123 commented 5 years ago

@Tvde1 not yet. I think it's been fixed in GHC so expect it to be fixed in the next release. In the mean time try my patch.

Tvde1 commented 5 years ago

Your patch fixes it. Thanks!

Yewert commented 5 years ago

Hi. Is it still not fixed? Also, it seems like @Kurren123 's patch is not working for me. Reinstalling elm compiler also didn't solve the problem.

upd: tried to run it from non-admin terminal and it worked....

Worble commented 5 years ago

Are you still using the .msi installer? It's out on npm now, and that one works fine for me.

aparent-emgs commented 5 years ago

Can confirm I still get the same exact error when running what is currently the last version of elm on npm (0.19.0-no-deps) in a command prompt in admin mode:

C:\emgsgit\derp  (derp@1.0.0)
λ npm install elm --save-dev

> elm@0.19.0-no-deps install C:\emgsgit\derp\node_modules\elm
> node install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN derp@1.0.0 No description
npm WARN derp@1.0.0 No repository field.

+ elm@0.19.0-no-deps
added 1 package from 1 contributor and audited 1 package in 2.334s
found 0 vulnerabilities

C:\emgsgit\derp  (derp@1.0.0)
λ npx elm init
Hello! Elm projects always start with an elm.json file. I can create them!

Now you may be wondering, what will be in this file? How do I add Elm files to
my project? How do I see it in the browser? How will my code grow? Do I need
more directories? What about tests? Etc.

Check out <https://elm-lang.org/0.19.0/init> for all the answers!

Knowing all that, would you like me to create an elm.json file now? [Y/n]: Y
Access violation in generated code when reading 000000000f841bb6

This is quite annoying. Any clue if this will be fixed anytime soon?

Kurren123 commented 5 years ago

@aparent-emgs have you tried my patch?

Kurren123 commented 5 years ago

@Worble may I ask why this was closed? Has it been resolved?

Worble commented 5 years ago

I had believed it to be fixed, or at the very least the npm binaries seemed to work regardless, but I can re-open it if it's still an issue.

aparent-emgs commented 5 years ago

@aparent-emgs have you tried my patch?

I was really trying to get the npm version of Elm 0.19 to work, as I need to still be able to use the 0.18 version (for older projects) which I installed with the installer back in the day, and which currently sits in my PATH. I wish to be able to use both (0.18 globally, and 0.19 locally through npm scripts), without having them collide with each other.

And yes @Worble, clearly, the issue is still present with any official version of Elm right now (I have also tried the installer on the official website, I get the same result). I feel like if the fix is as easy as rebuilding the compiler with a different version of GHC, why hasn't it yet been included in a bugfix? I don't think this should be left as is.

For now, I found a work-around which is to execute this before running any Elm commands in the command line, and it seems to work for me.

set __COMPAT_LAYER=
Kurren123 commented 5 years ago

@aparent-emgs I've released an npm version too which I am using right now.

Kurren123 commented 5 years ago

As for why this is being left as is, I believe NoRedInk are using linux for development which is why this bug isn't business critical for them.

Neppord commented 5 years ago

I have this issue, after updating windows 10 some time this week. I only get this issue I run it from the git bash terminal though and not from cmd.

I installed elm from the installer, and not from npm.

Kurren123 commented 5 years ago

@Neppord try my patch

theparitt commented 5 years ago

I have the same problem when I run "elm init" in VSCode's terminal. But I when use Windows Terminal ( cmd from Run... ) I have no problem. ( I use Windows 10 64-bit ) and elm 0.19

razzeee commented 5 years ago

the "vscode terminal" is not really the best reference here and that's certainly not elm's fault.

https://code.visualstudio.com/updates/v1_36#_launch-terminals-with-clean-environments

Stefan-Z-Camilleri commented 5 years ago

Same issue when running in cmd via IntelliJ's 'Terminal' pane... no issues with running directly via a normal cmd prompt.

Given that it is the same issue for both VScode and IntelliJ's terminal... I would say it might be something worth looking into from the Elm side.

rlefevre commented 4 years ago

@Stefan-Z-Camilleri @theparitt @Kurren123

Does it still happen with elm 0.19.1?

Mistuke commented 4 years ago

Hi, if this error still happens with GHCs newer than 8.4.2 please file a bug report and I will take a look. If using newer GHC also try compiling elm with -rtsopts and calling it with --install-seh-handlers=no to see if that works around the issue.