bitli

bitli

Instructions to run Elixir on Android

In case this is handy for other people, here is how you can run Elixir on Android:

  • Install https://termux.com/
  • apt update; apt upgrade to have your system up to date.
  • Install Erlang with apt install erlang, you should be able to run erl.
  • (check if an Elixir package was created so you can avoid the trouble of the remaining lines :slight_smile: )
  • Install wget with apt install wget (otherwise you will get bad address on any wget request).
  • Create a directory, and cd to it, for example: mkdir elixir; cd elixir.
  • Download the precompiled package from the link named Precompiled.zip file for the latest release in the page http://elixir-lang.org/install.html#precompiled-package.At time of this writing the command wget https://github.com/elixir-lang/elixir/releases/download/v1.4.2/Precompiled.zip should do this.
  • Unzip the files with unzip Precompiled.zip.
  • Go to directory bin.
  • Download the file termux-fix-shebang from the source at https://raw.githubusercontent.com/termux/termux-packages/master/packages/termux-tools/termux-fix-shebang. You can use wget https://raw.githubusercontent.com/termux/termux-packages/master/packages/termux-tools/termux-fix-shebang.
  • Execute sh termux-fix-shebang elixir iex elixircin the bin directory (sh is required as the path of the shebang of the script is not compatible with termux).
  • Execute which env and edit the first line of mix to set the path of command envto the one found by the command which.
  • Add export PATH=$PATH:$HOME/elixir/bin to your .bashrc or execute the command on your terminal.
    You can then mix and iex. An Android phone is not exactly a convenient development platform, but it was useful to me to learn Elixir when waiting for whatever.

Most Liked

soyjeansoy

soyjeansoy

here’s what i did (assuming you’re using termux):

  1. pkg install erlang
  • easiest way to install elixir is to use asdf-vm.
  1. git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.1

  2. Next do the following (im using zsh):

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
  1. restart termux session
  2. asdf plugin-add elixir
  3. asdf install elixir 1.8.1 or to find a version you can: asdf list-all elixir
  4. asdf global elixir 1.8.1 to set this version globally

you can visit their page on how to install asdf-vm.

happy coding!

NobbZ

NobbZ

Please try apt install --yes wget, for the older interface to apt, that meant to not ask but assume the operator knows what he is doing and install/remove everything. Can’t check though if it is still valid on the new interface which is used by termux.

PatNowak

PatNowak

Termux is awesome, but you might inform at the top of the post that this is the guide only for Android 5.0 and above. Thanks for the guide! :slight_smile:

NobbZ

NobbZ

But we are getting closer…

We do know now, that the script goes through escript and erlang now, but it seems as if escript requires the shebang to be exactly #!/usr/bin/env escript.

You’ll need to manually compile rebar dependencies by calling escript ~/.mix/rebar3 and hoping that simply copying arguments from mix’s error message will be sufficient.

NobbZ

NobbZ

Never tried. I SSH into real hardware or use my laptop, makes things much easier…


I didn’t tell you to run escript ~/.mix/rebar3 literally, I told you to run it with the arguments that mix reports when failing. In your posted error, mix tried to call /data/data/com.termux/files/home/.mix/rebar3 bare compile --paths "/data/data/com.termux/files/home/hello/_build/dev/lib/*/ebin", so you have to call escript ~/.mix/rebar3 bare compile --paths "/data/data/com.termux/files/home/hello/_build/dev/lib/*/ebin" and I’d guess you need to be in dependencies root-folder, but maybe you need to be somewhere else.

Where Next?

Popular in Guides/Tuts Top

Neurofunk
Hi folks! I wrote an article about BEAM and Haskell Interoperabilty. I'm describing the use of the erlang-ffi project, that impersonates ...
New
hlx
Typed my very first blog post ever, hope it will help some people https://henricus.xyz/roll-your-own-email-password-authentication-with...
New
drapermd
So here is the code I came up with to generically generate an array param that will be stored on a jsonb property in ecto. It only handl...
New
eclark
I’ve been working on a phoenix project lately and I wanted to use the latest versions of everything. Webpack 5 had some breaking changes ...
New
OvermindDL1
Ran across this recently, it's a set of cheatsheet inforgraphic things of the OTP behaviours on the BEAM:
New
berts-4865
Here is a quick guide to uploading a file from the browser to DO spaces. It is crude, but will hopefully save sometime time and frustrat...
New
jswny
Hello everyone, I recently redesigned my entire deployment process for Phoenix apps based on Docker. I really like the strategy that I ca...
New
fmcgeough
pipe into case? I use that fairly frequently…unless I’m misunderstanding what you’re wanting…could be… its still very early… str = "Hell...
New
f0rest8
Hi everyone, Just wanted to say that the new Self-referencing many to many guide is now up on the official Hex docs (at least I just not...
New
marcin
This post is intended to be a guide for others, I was running a remote debugger for the first time and appreciate feedback on how I could...
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement