erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.32k stars 2.94k forks source link

ERL-477: Erlang 20.0 fails to run on windows nanoserver #3277

Open OTP-Maintainer opened 7 years ago

OTP-Maintainer commented 7 years ago

Original reporter: acehack Affected version: OTP-20.0 Component: erts Migrated from: https://bugs.erlang.org/browse/ERL-477


Unable to load emulator DLL
(c:\erlang\erts-9.0\bin\beam.smp.dll)
Unable to load emulator DLL
(c:\erlang\erts-9.0\bin\beam.smp.dll)
OTP-Maintainer commented 7 years ago

john said:

Thanks for your report! Unfortunately we don't have a test environment for this, so it may take a while before we're able to reproduce it.

Did you use the installer, or did you copy the installation from a different computer?
OTP-Maintainer commented 7 years ago

acehack said:

So I tried to use the installer but that also does not work on windows nano server.  Microsoft has a new installer technology called WSA that is an extension of APPX for installing on nano server.  MSI and/or other installer technologies are not supported.

You can however xcopy install things, this works great for many other things that only have an MSI installer today.

I wrote a docker image that would install erlang using core server and then copy all the resulting files including the c++ runtime dlls from core server into nano server.  It looks like the dll in question has references to things like GDI and other win32 apis that are not available on nano server and that's why it fails to load.

I can provide the Dockerfile to recreate the problem if that is helpful.  It requires a version of windows with container support like Windows 10 and Docker for Windows installed.
OTP-Maintainer commented 7 years ago

john said:

An image would be much appreciated, though I probably won't have time to work on it until 20.1 is released.

Have you installed the "Microsoft-OneCore-ReverseForwarders-Package" package on the image in question?
OTP-Maintainer commented 7 years ago

bagofpecans said:

Hi,
I'm also looking into this topic, getting Erlang to run in nanoserver image (as RabbitMQ prerequisite).

A question google couldn't answer:

The Microsoft-OneCore-ReverseForwarders-Package seems to be no part of current RTM WindowsServer2016 image Nano packages, at least I cannot find it in there.
Does that mean it is a core component of nanoserver now? Would you still need to do anything on top of pulling the latest nanoserver base image to have the reverse-forwarder functionality?

@AceHack: Would you mind sharing your state of work in terms of the dockerfile? I can try to assist in the proceedings if that's possible.

Thanks!
OTP-Maintainer commented 7 years ago

john said:

bq. Does that mean it is a core component of nanoserver now? Would you still need to do anything on top of pulling the latest nanoserver base image to have the reverse-forwarder functionality?

I haven't gotten very far in my search either, but I've found various MSDN posts that say you have to specifically enable it (eg. https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/running-aspnet-core-with-iis-on-nano-server#installing-reverse-forwarders).
OTP-Maintainer commented 7 years ago

bagofpecans said:

Yeah, information is really sparse ...

On this page:

https://social.technet.microsoft.com/wiki/contents/articles/33805.nano-server-deploying-asp-net-5-site-on-internet-information-services-iis-web-server.aspx

It includes ominous line:

{quote}You will need the followings to host ASP.NET 5 application on Nano Server;

    Microsoft-NanoServer-IIS-Package
    Microsoft-OneCore-ReverseForwarders-Package (Not required since Windows Server 2016 GA/RTM)
    httpPlatformHandler v1.2 x64 Jump {quote}

which leads me to presume it is somehow part of RTM nanoserver now?

@AceHack: Did what you described and arrived at the "Unable to load .." part as well

FYI, I asked a question at the MS forum as well hoping for some info into the package thing, it is here:

https://social.msdn.microsoft.com/Forums/en-US/5c35e460-011d-4f15-80c4-1e97c6d2c103/microsoftonecorereverseforwarderspackage-for-nanoserver-images?forum=windowscontainers

Feel free to participate ;)

Thanks!
OTP-Maintainer commented 7 years ago

bagofpecans said:

Found it it seems:

{quote}Thank you for the feedback. We’ve listened to your feedback and have included the reverse forwarders by default in Nano Server starting with TP5.{quote}

from:

https://windowsserver.uservoice.com/forums/295068-core-server/suggestions/11435964-reverse-forwarders-should-be-included-by-default

So this should be a given for newer image.

Unfortunately this might make it harder to get Erlang on nanoserver running I guess.
OTP-Maintainer commented 7 years ago

acehack said:

Docker file to reproduce the issue
OTP-Maintainer commented 7 years ago

acehack said:

I've attached a docker file to reproduce the issue.  What's very interesting is if you replace the line

FROM microsoft/nanoserver
with
FROM microsoft/nanoserver-insider-powershell

This is assuming you are running an insider build of windows that will support the image.
You get a completely different error.
I think this might be better?

The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
Error: Failed to initialize erlang distribution: {{shutdown,
                                                   {failed_to_start_child,
                                                    auth,
                                                    {"Failed to create cookie file 'c:/Windows/.erlang.cookie': eacces",
                                                     [{auth,init_cookie,0,
                                                       [{file,"auth.erl"},
                                                        {line,286}]},
                                                      {auth,init,1,
                                                       [{file,"auth.erl"},
                                                        {line,140}]},
                                                      {gen_server,init_it,2,
                                                       [{file,
                                                         "gen_server.erl"},
                                                        {line,365}]},
                                                      {gen_server,init_it,6,
                                                       [{file,
                                                         "gen_server.erl"},
                                                        {line,333}]},
                                                      {proc_lib,
                                                       init_p_do_apply,3,
                                                       [{file,"proc_lib.erl"},
                                                        {line,247}]}]}}},
                                                  {child,undefined,
                                                   net_sup_dynamic,
                                                   {erl_distribution,
                                                    start_link,
                                                    [['rabbitmq-cli-46',
                                                      shortnames],
                                                     false]},
                                                   permanent,1000,supervisor,
                                                   [erl_distribution]}}.
OTP-Maintainer commented 7 years ago

acehack said:

Working erlang and rabbit on latest nanoserver insider edition
OTP-Maintainer commented 7 years ago

acehack said:

So I was able to get erlang and rabbitmq working on the latest preview of windows nanoserver insider edition.  It's a bit kludgy but it's working!!!
I guess microsoft added whatever was missing in the latest edition to make things work.
Hope this image can help someone else.

You can type "build-image.cmd" to created the docker image
"run-containers.cmd" will startup two instance of rabbit one with host name "rabbitmq" and one with host name "joinmq"
One interesting thing here is the .erlang.cookie file.  I had to do some playing to get the two rabbits to have the same .erlang.cookie file but not embed it in the image so it could be replaced at runtime.
"log-containers.cmd" will show you once the rabbit images have started fully.
"join-cluster.cmd" will join the two instances into a cluster.
OTP-Maintainer commented 7 years ago

bagofpecans said:

Hi,

thanks for the image, good find!

I am still interested in getting it to run on a current nanoserver image (for near future production use maybe).
Any further clues obtained what might be the problem in the current nanoserver variant now you got it running? ?

It seems strange to me that the insider image allows it to run since I had the impression even more stuff was removed from them to slim them further down...well.
Thanks for sharing.
OTP-Maintainer commented 6 years ago

chiel said:

I would also be very interested in a solution for Erlang not running on Windows nanoserver. I'm trying to build a set of Docker images (containing either a node, tomcat, MongoDB or RabbitMQ application) on Windows server 2016. It is very frustrating to see that RabbitMQ is the only application not working with the nanoserver image. This is making the total build size of my images ~13GB instead of ~2GB (still quite large but more portable than a file 10GB larger). 

Based on the error I receive (Unable to load emulator DLL (c:\erlang\erts-8.3\bin\beam.smp.dll)) you would say some Windows system file is missing or needs to be updated but I can't figure out which one so far. Simply deleting the nanoserver image its c:/windows/system32 directory and replacing it with the one from the windowsservercore image is not as easy as it sounds. Even extracting the system32 directory from the images to compare them does not seem to be feasible (I get a 'unexpected EOF' error).
OTP-Maintainer commented 6 years ago

bhaal22 said:

I just tested on windows server 2016 1709 and it is working fine on nanoserver.

cf this github repo: https://github.com/gsx-solutions/erlang-otp-win/tree/master/nanoserver/1709

for the windows10 nanoserver:latest it does not work.
Issue while loading beam.smp.dll

It looks to be related to the beam.smp.dll dependencies such a gdi32 / user32 dlls.

I wonder if dynamic library loading behavio has been changed in nanoserver:1709

*EDIT* I just updated my windows 10 to the 1709 version. And using nanoserver:1709 as a base image. It is working fine.
OTP-Maintainer commented 6 years ago

xied75 said:

Dear all,
Great to see you guys have done this much, very helpful.

May I take this opportunity here to ask/suggest/volunteer the following:
1. Make the Erlang for Windows Server Zip Deployable, i.e. Portable, rather than using Installer.

Benefit:
One can easily download a zip of a release of Erlang, unzip to any destination folder, and the Erlang is ready to go. In the case for Windows Nano, we don't need to grab a full windowsservercore to do multi-staged building.

Other similar systems that offer this experiences: neo4j, mongodb, git for Windows, even rabbitmq...

I can see that current Erlang installer is using NSIS, by looking at the script, it wasn't doing anything exotic. Should be straight forward to offer a zip instead. Besides, I noticed there is an "install.exe" which was compiled by Makefile in the build, which again is doing some simple file copying, ideally should be replaceable by a script, i.e. Powershell.

I might be missing some impediment here, but otherwise please comment/advise. If this should rather open an new Issue, then do let me know.

Best regards,

Dong Xie