首页 > 解决方案 > 如何在三星 Dex 内的 termux 上运行 rails 服务器?

问题描述

三星 Dex 只是一个声明,因为它将 termux 处理为任何 Android 环境。

我想使用 termux 在我的 android 环境中运行本地 rails 服务器。我想知道我必须配置哪些依赖项和安装才能成功。

标签: ruby-on-railstermuxsamsung-dex

解决方案


Termux 上的 Rails 6.0.3.2

pkg upgrade
pkg install ruby vim git nodejs

nokogiri 将在本地构建,并且需要 ff 包,并且需要 pkg-config 来找到它们:

  • libxml-2
  • libxslt
  • libexslt

所以安装 pkg-config

pkg install pkg-config

运行时会安装 libxml-2 (2.9.10-3):

pkg install build-essentials

pkg 安装 libxslt

pkg install libexslt 不起作用,我猜它已经与 libxslt 捆绑在一起

尝试运行:

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

nokogiri 安装成功

最后安装没有文档的rails,我们不希望它们占用空间:

gem install rails --no-doc

用于 sqlite3 gem 的 libsqlite

pkg install libsqlite

在运行 rails new 之前先安装 yarn:

pkg install yarn

运行时,ffi 和 rb-inotify 已经包含在 bundle 中: rails new

gem install tzinfo-data

运行 rails 服务器时出现 tzinfo-data 问题:rubygems/rubygems#3212

尝试删除 Gemfile.lock 并再次运行捆绑安装。或运行 bundle update tzinfo

对我有用的是从以下位置更改 Gemfile 中的 tzinfo-data gem:

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

宝石'tzinfo-data'

然后删除 Gemfile.lock 并再次运行 bundle install

现在通过运行服务器rails serverlocalhost:3000在您设备上的任何浏览器上浏览。

在我们创建第一个控制器并更改路由根路径之前,一切都很好:

rails generate controller Dashboard index

在 config/routes.rb 文件中:

root to: 'dashboard#index'

然后再次浏览到我们的浏览器localhost:3000会给我们这个 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:
{
}

尝试在测试环境中运行编译:

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

这返回Errno::EACCES: Permission denied @ rb_sysopen

在撰写本文时,我还没有找到解决此问题的方法。


推荐阅读