Deploying elixir on windows 10

Hello together, I hope I can post a quick question here related to deployment problems:

I am currently struggling to get a simple release running on windows 10 with distillery. I’ve tried following the guide on their website, but as soon as I try running the release it crashes with Powershell errors (tested on three computers).

Is there anything in the docs with additional Infos for Windows? Should I create a new topic with the exact steps I’ve taken and the error message?

Yes, please open a new Thread, and also please add what kind of error messages you see when you try to start your application.

Inlcuding the steps you have taken to build and move the release is a big plus as well.


edit

Nevermind, I’ll move this post into a new thread, still you’ll need to provide errors as you see them and the steps taken to create/move the release.

1 Like

Thanks for the reply! I will write down the steps i took as best as possible. (please forgive me my german folder structure and logs…)

I started with a blank project using mix:

PS E:\Projektversuche\Elixir> mix new deploytest
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/deploytest.ex
* creating test
* creating test/test_helper.exs
* creating test/deploytest_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd deploytest
    mix test

Run "mix help" for more commands.
PS E:\Projektversuche\Elixir> cd .\deploytest\
PS E:\Projektversuche\Elixir\deploytest> code .

After opening it in VS Code i modified my application dependencies to include Distillery:

defp deps do
  [
    {:distillery, "~> 2.0"}
  ]
end

Afterwards i continued in the shell, simply following the steps described in the distillery documentation about getting your dependencies, initializing the release configuration and then building the release and running it:

PS E:\Projektversuche\Elixir\deploytest> mix do deps.get, compile
Resolving Hex dependencies...
Dependency resolution completed:
  artificery 0.4.1
  distillery 2.0.12
All dependencies are up to date
==> artificery
Compiling 10 files (.ex)
Generated artificery app
==> distillery
Compiling 33 files (.ex)
Generated distillery app
==> deploytest
Compiling 1 file (.ex)
Generated deploytest app
PS E:\Projektversuche\Elixir\deploytest> mix release.init
e[36m
An example config file has been placed in rel/config.exs, review it,
make edits as needed/desired, and then run `mix release` to build the releasee[0m
PS E:\Projektversuche\Elixir\deploytest> mix release
==> Assembling release..
==> Building release deploytest:0.1.0 using environment dev
==> You have set dev_mode to true, skipping archival phase
Release successfully built!
To start the release you have built, you can use one of the following tasks:

    # start a shell, like 'iex -S mix'
    > _build/dev/rel/deploytest/bin/deploytest.bat console

    # start in the foreground, like 'mix run --no-halt'
    > _build/dev/rel/deploytest/bin/deploytest.bat foreground

    # start in the background, must be stopped with the 'stop' command
    > _build/dev/rel/deploytest/bin/deploytest.bat start

If you started a release elsewhere, and wish to connect to it:

    # connects a local shell to the running node
    > _build/dev/rel/deploytest/bin/deploytest.bat remote_console

    # connects directly to the running node's console
    > _build/dev/rel/deploytest/bin/deploytest.bat attach

For a complete listing of commands and their use:

    > _build/dev/rel/deploytest/bin/deploytest.bat help
PS E:\Projektversuche\Elixir\deploytest> .\_build\dev\rel\deploytest\bin\deploytest.bat console


    Verzeichnis: E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       05.04.2019     11:19                var
Set-Content : Es wurde kein Parameter gefunden, der dem Parameternamen "InputObject" entspricht.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\deploytest.ps1:103 Zeichen:77
+ ... -path $Env:RELEASE_MUTABLE_DIR "WARNING_README") -InputObject $warnin ...
+                                                      ~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Content], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand



    Verzeichnis: E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\var


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       05.04.2019     11:19                log
join-path : Das Laufwerk wurde nicht gefunden. Ein Laufwerk mit dem Namen "
    $bin = whereis-erts-bin
    if (($bin -eq $null) -or ($bin -eq "")) {
        log-error "Erlang runtime not found. If Erlang is installed, ensure it is in your PATH"
    }
    if (($IsWindows -eq $true) -or (($IsWindows -eq $null) -and ($env" ist nicht vorhanden.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\libexec\win\erts.ps1:123 Zeichen:17
+         $erl = (join-path $bin "erl.exe")
+                 ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (
    $bin = whe...ull) -and ($env:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Der Ausdruck nach "&" in einem Pipelineelement hat ein ungültiges Objekt erzeugt. Der Ausdruck muss einen Befehlsnamen, Skriptblock oder ein CommandInfo-Objekt ergeben.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\libexec\win\erts.ps1:129 Zeichen:7
+     & "$erl" @base_args @args
+       ~~~~~~
    + CategoryInfo          : InvalidOperation: (:String) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression

Error occurred! Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running
join-path : Das Laufwerk wurde nicht gefunden. Ein Laufwerk mit dem Namen "
    $bin = whereis-erts-bin
    if (($bin -eq $null) -or ($bin -eq "")) {
        log-error "Erlang runtime not found. If Erlang is installed, ensure it is in your PATH"
    }
    if (($IsWindows -eq $true) -or (($IsWindows -eq $null) -and ($env" ist nicht vorhanden.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\libexec\win\erts.ps1:123 Zeichen:17
+         $erl = (join-path $bin "erl.exe")
+                 ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (
    $bin = whe...ull) -and ($env:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Der Ausdruck nach "&" in einem Pipelineelement hat ein ungültiges Objekt erzeugt. Der Ausdruck muss einen Befehlsnamen, Skriptblock oder ein CommandInfo-Objekt ergeben.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\libexec\win\erts.ps1:129 Zeichen:7
+     & "$erl" @base_args @args
+       ~~~~~~
    + CategoryInfo          : InvalidOperation: (:String) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression

join-path : Das Laufwerk wurde nicht gefunden. Ein Laufwerk mit dem Namen "
    $bin = whereis-erts-bin
    if (($bin -eq $null) -or ($bin -eq "")) {
        log-error "Erlang runtime not found. If Erlang is installed, ensure it is in your PATH"
    }
    if (($IsWindows -eq $true) -or (($IsWindows -eq $null) -and ($env" ist nicht vorhanden.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\libexec\commands\win\console.ps1:3 Zeichen:10
+ $werl = (join-path $bin werl)
+          ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (
    $bin = whe...ull) -and ($env:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand


HasMoreData   : True
StatusMessage :
Location      : localhost
Command       :
                    start-sleep -Second 2
                    run-hooks -Phase post_start

JobStateInfo  : Running
Finished      : System.Threading.ManualResetEvent
InstanceId    : 2c97935b-a350-4956-ae9c-2a5a149b49e5
Id            : 1
Name          : post_start hooks
ChildJobs     : {Job2}
PSBeginTime   : 05.04.2019 11:19:49
PSEndTime     :
PSJobTypeName : BackgroundJob
Output        : {}
Error         : {}
Progress      : {}
Verbose       : {}
Debug         : {}
Warning       : {}
Information   : {}
State         : Running

Der Ausdruck nach "&" in einem Pipelineelement hat ein ungültiges Objekt erzeugt. Der Ausdruck muss einen Befehlsnamen, Skriptblock oder ein CommandInfo-Objekt ergeben.
In E:\Projektversuche\Elixir\deploytest\_build\dev\rel\deploytest\releases\0.1.0\libexec\commands\win\console.ps1:23 Zeichen:3
+ & $werl @argv
+   ~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression



PS E:\Projektversuche\Elixir\deploytest>

Sorry for the long post, but i didn’t want to leave out any log messages that might be important…
Thanks to anyone helping!
(P.S.: Really enjoying writing Elixir, just currently struggling trying to not only run my programs via iex…)

In case the german error messages are a problem i tried to translate them (as best as i could…):

  • “Set-Content : Es wurde kein Parameter gefunden, der dem Parameternamen “InputObject” entspricht.” = No value for the parameter “InputObject” was found
  • “join-path : Das Laufwerk wurde nicht gefunden. Ein Laufwerk mit dem Namen […] ist nicht vorhanden.” = The drive was not found. A drive with the name […] is not existent.
  • “Der Ausdruck nach “&” in einem Pipelineelement hat ein ungültiges Objekt erzeugt. Der Ausdruck muss einen Befehlsnamen, Skriptblock oder ein CommandInfo-Objekt ergeben.” = The term after the “&” in the pipeline (?) created an invalid object. The term needs to be a command name, script block or a commandinfo-object.
1 Like

@bitwalker, can you read anything from those logs?

Hi @IloSophiep,

can you give this one a shot?

mix new deploymenttest2

cd deploymenttest2

# Instead of {:distillery, "~> 2.0"}, please try 
# {:distillery, git: "https://github.com/chgeuer/external_bitwalker_distillery.git"}

mix do deps.get

mix release.init

set MIX_ENV=dev

mix release

_build\dev\rel\deploymenttest2\bin\deploymenttest2.bat foreground

I did a few tweaks on https://github.com/chgeuer/external_bitwalker_distillery/commit/2232cd126997131d4d3d653a26b9dff5cee2e06e … When I try this, I bump into this in the end, but that’s probably because I didn’t configure anything with the release:

chgeuer@X1CARBON C:\github\chgeuer\deploymenttest2
$ _build\dev\rel\deploymenttest2\bin\deploymenttest2.bat foreground


    Directory: C:\github\chgeuer\deploymenttest2\_build\dev\rel\deploymenttest2


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2019-04-05     23:48                var


    Directory: C:\github\chgeuer\deploymenttest2\_build\dev\rel\deploymenttest2\var


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2019-04-05     23:48                log
init terminating in do_boot (cannot expand $ERTS_LIB_DIR in bootfile)

Crash dump is being written to: erl_crash.dump...done
Error occurred! Unable to configure release!

Today, I did a fresh install of otp_win64_21.3.exe and elixir-v1.8.1-setup.exe on Windows 10 version 1809 Build 17763.379 x64… The mix release is in an administrative cmd.exe session, because distillery docs said something about symlinks and stuff.

Thank you for your response!

When i use your customized version of distillery (at least that’s how i understood what you did), i also end up with the error message you got:

PS C:\Users\ilosophiep\Documents\Entwicklung\Elixir\deploytest2> _build/dev/rel/deploytest2/bin/deploytest2.bat foreground


    Directory: C:\Users\ilosophiep\Documents\Entwicklung\Elixir\deploytest2\_build\dev\rel\deploytest2

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        06.04.2019    09:18                var

    Directory: C:\Users\ilosophiep\Documents\Entwicklung\Elixir\deploytest2\_build\dev\rel\deploytest2\var

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        06.04.2019    09:18                log
init terminating in do_boot (cannot expand $ERTS_LIB_DIR in bootfile)

Crash dump is being written to: erl_crash.dump...done
Error occurred! Unable to configure release!

You wrote

but that’s probably because I didn’t configure anything with the release

which makes me think i can fix that error myself, because i simply forgot to do some additional steps after mix release.init but before mix release? Any pointers for that, because reading through the distillery docs it seems like they instantly build the release after initializing.

I am using PowerShell Core 6, running as admin.

Running with any of the other start params (console and start) results in the same error.

Thanks again for your help!

Edit: Looking for the new error message i seem to find a few issues and posts here on the forum.

  • Here, but when i delete the _build directory or remove the smart_clean.boot it still doesn’t seem to work.
  • Here, but i’m not sure i understand the “fix”. The thread makes it sound like a problem between versions? So here is the result of my elixir --version, in case that helps
So is it a problem that once it's Erlang/OTP 21 and once it's Erlang/OTP 20..?
PS C:\Users\ilosophiep\Documents\Entwicklung\Elixir\deploytest2> elixir --version
Erlang/OTP 21 [erts-10.1] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Elixir 1.8.1 (compiled with Erlang/OTP 20)

I believe that the template for erts.ps1 needs to be fixed by @bitwalker upstream. I just did a naive first attempt in my clone. In addition, you certainly need to properly use distillery in your own project, i.e. tweak the distillery config etc. I won’t have time today to look at it, certainly give it a shot tonight.

And @IloSophiep one remark: if you have a Win10 version where you can run the Windows Subsystem for Linux WSL, that’s certainly also a good way to develop. Just to be clear, as Microsoft employee, I’m incredibly happy that Erlang, Elixir and Distillery support Windows, but WSL gives a damn good Elixir dev environment, just sayin :slight_smile:

I am now using a “workaround”. When i went and created the release in a docker container based on ubuntu everything worked flawlessly with the same steps i took in my Windows environment.

With that i decided that i would probably be fine to run my application either on a native ubuntu host that can run the release i created in docker - or i would run a docker container executing my release (that’s what i currently did for testing on my local machine). I am thinking about using elixir in my bachelor thesis and being able to “build/release and run” an application this way should be enough for my needs.

That being said it feels like there is a bug with distillery on windows 10, because i don’t think taking the same steps in two different environments should end up with different results, right? If i understand correctly @bitwalker is the brain behind distillery? Should i create an issue on the github page with the information provided here? There seem to be a few issues regarding windows already, but none seem to be the one i am having (at least i hope i didn’t miss it)…

As @chgeuer already pointed out, the error seems to be in powershell scripts that orchestrate the release.

So, yeah, those massively depend on the host operating system.

But as it seems, https://github.com/bitwalker/distillery/issues/599 is at least partially related.