【问题标题】:How to run rails server on termux, inside Samsung Dex?如何在三星 Dex 内的 termux 上运行 rails 服务器?
【发布时间】:2019-08-17 17:38:09
【问题描述】:

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

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

【问题讨论】:

    标签: ruby-on-rails termux samsung-dex


    【解决方案1】:

    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 包含在内: 新的轨道

    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]

    gem 'tzinfo-data'

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

    现在通过rails server 运行服务器并在您设备上的任何浏览器上浏览localhost: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

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

    【讨论】:

      【解决方案2】:

      步骤:

      1. 安装 termux 并运行它。运行以下命令:
      2. apt 更新
      3. apt 升级
      4. apt install ruby​​ cmake sqlite libxslt node.js yarn
      5. xcode-选择安装(this command might be avoidable)
      6. gem 安装导轨
      7. pkg 安装 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:安装
      11. 在您处理的每个 rails 项目中,修改 gemfile 如下: 替换

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

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

      正如here解释的那样

      这至少应该可以解决我遇到的大部分问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-09-24
        • 1970-01-01
        • 1970-01-01
        • 2012-04-24
        • 1970-01-01
        • 2014-12-01
        • 2014-12-26
        相关资源
        最近更新 更多