Fl4m3Ph03n1x

Fl4m3Ph03n1x

Background

I am creating a simple Phoenix umbrella application to run on a client’s Windows 11 machine and my objective is to have something like an .exe file for running said application.

Code

I am creating the application and releasing it using Elixir’s normal release procedure, using the commands:

mix phx.new demo --umbrella --no-ecto --no-dashboard --no-gettext --no-mailer
cd demo_umbrella
mix deps.get

# set MIX_ENV=prod before doing this last step!
mix release demo

For those of you curious, this is the releases function I am using inside my mix.exs:

  defp releases,
    do: [
      demo: [
        applications: [
          demo_web: :permanent,
          runtime_tools: :permanent
        ],
        include_executables_for: [:windows]
      ]
    ]

Now, this basic setup will create a .bat file: _build\prod\rel\demo\bin\demo.bat that I can start and stop via the following commands: _build\prod\rel\demo\bin\demo {start | stop}.

Problems & Research

Users that know programming can simply open a terminal in Windows, type _build\prod\rel\demo\bin\demo start and the application will launch (accessible via localhost:4000).

But users normally don’t have such knowledge. So I want something as close to an .exe file as possible.

I have tried using Bakeware:

And its spiritual successor, Burrito:

Unfortunately, both fail to work for Windows 11. This leads me to try the shortcut approach.
Here I create Windows shortcut to demo.bat and I specify in the target path the commands:

Which in this case will be %windir%\system32\cmd.exe /c start "" "%CD%\demo.bat" start

Now, all is fine and dandy, but there is a problem:

  1. the console always appears.

Questions

So this leaves me to the following questions:

  1. How do I prevent the console from showing?
  2. Does demo.bat include the erlang VM and the elixir version needed to run the application? Or do I need to have those installed in the client’s machine ?
  3. I am under the impression that Elixir releases are supposed to include everything needed (https://elixir-lang.org/getting-started/mix-otp/config-and-releases.html):

A release is a self-contained directory that consists of your application code, all of its dependencies, plus the whole Erlang Virtual Machine (VM) and runtime. Once a release is assembled, it can be packaged and deployed to a target as long as the target runs on the same operating system (OS) distribution and version as the machine that assembled the release.

, but in case this bat file does not include everything, how do I fix this?

Showing Posts 1 to 10

LostKobrakai

LostKobrakai

Release inclde everything needed for you to be able to run it on the target system. You can do that using the .bat. It’s however not meant to build a single/standalone executable (.exe / binaries on other os’s).

Yes(ish). It includes everything so an OTP/Elixir installation is not necessary. There might be other lower level dependencies left though, which are still required, but often expected to exist on target systems.

What do you think it doesn’t include, that would be needed to run the release?

cmo

cmo

I’m surprised burrito doesn’t work. I’ve used it on windows a bunch of times.

Elixir Desktop uses a vbscript to launch the app. It’s not a pretty solution imo but it works.

cmo

cmo

So, burrito doesn’t build on WIndows anymore. I pushed a PR to fix the issue you’re hitting but there are other hurdles in the Zig code. Best to build from a linux box for now.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Since my use case is an Elixir Desktop application, I am unsure that :wx and all of its dependencies will be inside the bat created.

I searched the code for any files with a .vb extension but could not find. Can you point me to the file where this happens?

I understand that you can theoretically convert a VB6 script into an .exe file, so this could actually work, even if a lot of manual work is needed.

Since I am doing this for Windows clients, I need to do everything in a Windows machine. This is sadly not a viable option for me :frowning:

LostKobrakai

LostKobrakai

:wx will be in the release (if you setup the dependency in mix.exs). I don’t think wxwidgets specifically are included in the release. How external (native) dependencies are handled always depends on the application integrating with that dependency. That’s nothing elixir (or OTP for the matter) could affect in a general application independant way.

Also nothing will be “in the bat” specifically. The release only works as a whole with all the files within it. The bat is only the entry point.

While cross compilation is not necessarily an easy topic it is not impossible to build for windows from linux.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

This is very important and something I don’t quite understand.
Say I have created my release files using mix realease. What files do I need to put in my clients machine, for the client to be able to run the application?

I take it from your comment that I will need more than simply demo.bat.
What folders do I need ?

Do I need the full _build/prod folder? Maybe something less?

Why would this be preferable? If the support for Windows is not ideal in Windows machines, how would cross-compilation improve the situation? If you have some articles/ideas on this, I would really like to check them out.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Answer

Following an SO post:

I was able to create a shortcut that achieves my purposes, using VB as well. At the very least, this will launch the application. Closing may be another concern and I still need to test this with Elixir Desktop. However, these are questions that likely deserve their own posts, so if I find the need, I will leave them for later.

Instructions

  1. Follow instructions to create the project from the question above (you may need to enable server options in config/prod.exs)

  2. Go to demo_umbrella\_build\prod\rel\demo\bin where the newly created demo.bat file is

  3. Create a file called invisible.vbs and add in the following content:

CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, False
  1. Create a Windows shortcut, that looks like this:

The value on the Target field is:

%windir%\system32\wscript.exe invisible.vbs "demo.bat start"

  1. Upon clicking the shortcut, the application will be launched behind the scenes and you will be able to check it under localhost:4000.

This shortcut will run the files from the folder it is in, so you can safely move things around provided you always keep it in the same folder the rest of the files are.

Being a shortcut, it also means you can change the icon to anything you want.

LostKobrakai

LostKobrakai

If you stick to the default release root then everything within _build/MIX_ENV/rel/YOUR_APP is “the release”. You need everything in there in the same places relative to each other. Or said otherwise. Don’t attempt to move pieces within that folder. You can add the :tar release step in mix.exs to get a .tar archive of the same contents, though as a single archive file.

I didn’t quickly find any documentation on :wx if you need to install wxwidgets on a target machines as well, or if it’s only a build time dependency. If you have a spare machine you could probably test it though.

I wasn’t arguing that it’s preferable, but that it’s not impossible. How difficult it would be depends on what all you need to build and actually cross compile.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

This is rather interesting. However, if I choose to do it that way, how will I be able to create a shortcut to demo.bat ?

Would I not have to unzip the file before? (thus ending with the same thing?)

LostKobrakai

LostKobrakai

You don’t. It’s not meant to be “an executable”, but just an easier way to ship to a target computer as one and extract there.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews