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:
- the console always appears.
Questions
So this leaves me to the following questions:
- How do I prevent the console from showing?
- Does
demo.batinclude 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 ? - 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?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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
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
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
Since my use case is an Elixir Desktop application, I am unsure that
:wxand all of its dependencies will be inside thebatcreated.I searched the code for any files with a
.vbextension 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
.exefile, 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
LostKobrakai
:wxwill 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
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/prodfolder? 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
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
Follow instructions to create the project from the question above (you may need to enable server options in
config/prod.exs)Go to
demo_umbrella\_build\prod\rel\demo\binwhere the newly createddemo.batfile isCreate a file called
invisible.vbsand add in the following content:The value on the
Targetfield is:%windir%\system32\wscript.exe invisible.vbs "demo.bat start"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
If you stick to the default release root then everything within
_build/MIX_ENV/rel/YOUR_APPis “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:tarrelease step inmix.exsto get a.tararchive of the same contents, though as a single archive file.I didn’t quickly find any documentation on
:wxif you need to installwxwidgetson 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
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
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.