Getting ‘heroku’ installed with Termux on Android

I have this personal project where I need to regularly update PostgreSQL database from a dump file so that users can view the most up-to-date information every week. My web hosting company, ICD Soft, offers MySQL but not PostgreSQL. I could convert a PostgreSQL dump to MySQL but doing this every time may be time consuming and there is a chance where someone who has no knowledge of database might need to handle this task if I'm not available, so converting was out of questions.

Another option was to look for a free service that offers managing a remote PostgreSQL server. Then, I found Heroku. It seems to offer what I want. So, I decided to give it a try.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

As usual, I do most of developing work on my cell phone (Samsung Note 8), I tried to install heroku on Termux. Installation was fairly simple after tweeking a bit.

PHP Installation:

First thing first, I'll be using PHP to develop my site with heroku. So, PHP needs to be installed on Termux:$ apt-get update $ apt-get install php

Composer Installation:

Secondly, composer (PHP dependent management tool) needs to be installed:$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" $ php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" $ php composer-setup.php $ php -r "unlink('composer-setup.php');"

Standard Heroku Installation:

Now follow the instruction from Heroku documentation site with some tweeks for Termux: $ wget http://cli-assets.heroku.com/heroku-cli/channels/stable/heroku-cli-linux-x64.tar.gz -O heroku.tar.gz $ tar -xvzf heroku.tar.gz -C heroku $ mv heroku /data/data/com.termux/files/usr/lib/heroku $ ln -s /data/data/com.termux/files/usr/lib/heroku/bin/heroku /data/data/com.termux/files/usr/bin/heroku

Tweekings 1 - heroku script:

Installation of Heroku is now done, but it doesn't work as is because I just installed Linux version of tarball in Termux on Android. If heroku is executed now, it'll give you some error messages:$ heroku bash: /data/data/com.termux/files/usr/bin/heroku: /usr/bin/env: bad interpreter: No such file or directory

This is because the heroku script is pointing to /usr/bin/env for bash. This needs to be changed to correct path for Termux:$ cd /data/data/com.termux/files/usr/lib/heroku/bin/ $ vim heroku #!/usr/bin/env bash set -e ... Change the first line from #!/usr/bin/env bash to #!/data/data/com.termux/files/usr/bin/env bash, and save the file.

Tweekings 2 - node binary:

The tarball downloaded contains node.js binary for auto update but this binary doesn't seem to work in Termux and it would give an Exec format error:$ heroku /data/data/com.termux/files/usr/bin/heroku: line 29: /data/data/com.termux/files/usr/lib/heroku/bin/node: cannot execute binary file: Exec format error

To work around this problem, I installed node.js separately and made a symlink. This seemed working and no more Exec format error:$ apt-get install nodejs ... $ cd /data/data/com.termux/files/usr/lib/heroku/bin $ mv node node.old $ ln -s ../../../bin/node node $ heroku --version heroku-cli/6.15.31-958455a (android-arm64) node-v8.10.0 $ heroku login Enter your Heroku credentials: Email: *** Password: *** Logged in as *** $

voilà, logged in successfully.

That's all!
-gibb

9 comments

  1. Ramgopal Menon

    For OnePlus 5T, under Standard Heroku Installation section, please make sure you check the structure of the extracted ‘heroku’ folder.
    When I did this step everything was under heroku/heroku-cli-v6.99.0-ec9edad-linux-x64 instead and I had to move every thing to heroku/
    Also for Tweekings 1, before using vim or vi editor, make sure you have something in Android to type keys like Ctrl, Alt and ESC, and also the arrow keys.
    I found Hacker’s Keyboard worthwhile.
    Thanks Gibb! This helps.

  2. Xnehaxixh

    Thanks a lot for making this! You are the only person who made this tutorials and I really appreciate it.
    Sad thing is that nobody ever commented on this. So I will surely do because you saved my time 😀

  3. remo773

    $ heroku login

    it open chrome automatically for login authentication
    btw nice post…
    keep it bro…

  4. Alex

    Thanks buddy, helped a lot. Also, it would be better if you incorporate Ramgopal Menon’s comment in the post as it was really helpful as well.

Leave a Reply to remo773 Cancel reply

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>