-1

Samsung Dex in only an aclaration, as it handles termux as any Android environment.

I want to run a local rails server in my android environment by using termux. I want help to know what dependencies and installations I have to configure to be successful.

Alvaro Rodriguez Scelza
  • 3,643
  • 2
  • 32
  • 47

2 Answers2

0

Rails 6.0.3.2 on Termux

pkg upgrade
pkg install ruby vim git nodejs

nokogiri will build natively and would need the ff packages and will need pkg-config to find them:

  • libxml-2
  • libxslt
  • libexslt

so install pkg-config

pkg install pkg-config

libxml-2 (2.9.10-3) is installed when you run:

pkg install build-essentials

pkg install libxslt

pkg install libexslt will not work, I guess it's already bundled with libxslt

tried running:

gem install nokogiri -- --use-system-libraries

nokogiri was successfully installed

finally install rails without docs, we dont want them taking up space:

gem install rails --no-doc

libsqlite for sqlite3 gem

pkg install libsqlite

install yarn first before running rails new:

pkg install yarn

ffi and rb-inotify are already included via bundle when you run: rails new

gem install tzinfo-data

tzinfo-data issue when running rails server: rubygems/rubygems#3212

try removing the Gemfile.lock and running the bundle install again. or Running bundle update tzinfo

What worked for me is changing tzinfo-data gem in Gemfile from:

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

to

gem 'tzinfo-data'

then deleting Gemfile.lock and running bundle install again

now run the server via rails server and browse localhost:3000 on any browser on your device.

All is well until we create our first controller and change the routes root path:

rails generate controller Dashboard index

and on config/routes.rb file:

root to: 'dashboard#index'

then browsing again to our browser on localhost:3000 gives us this ActionVew::TemplateError:

Webpacker can't find application in <my app path>/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}

tried running compilation on test environment:

RAILS_ENV=test NODE_ENV=test bundle exec rails webpacker:compile

this returns Errno::EACCES: Permission denied @ rb_sysopen

I haven't found a solution to this issue at the time of this writing.

Dale Ryan
  • 473
  • 4
  • 9
-1

Steps:

  1. Install termux and run it. Run following commands:
  2. apt update
  3. apt upgrade
  4. apt install ruby cmake sqlite libxslt node.js yarn
  5. xcode-select install (this command might be avoidable)
  6. gem install rails
  7. pkg install wget
  8. wget https://github.com/termux/termux-packages/files/2912002/fix-ruby-bigdecimal.sh.txt
  9. bash fix-ruby-bigdecimal.sh.txt This later 3 commands are for fixing bigdecimal problem
  10. rails webpacker:install
  11. Inside each rails project you work on, modify gemfile as follows: replace

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

for

gem 'tzinfo-data', '~> 1.2019', '>= 1.2019.2'

As explained here

This should at least solve most of my encountered problems

Alvaro Rodriguez Scelza
  • 3,643
  • 2
  • 32
  • 47