【问题标题】:TypeError when running rails commands with jruby使用 jruby 运行 rails 命令时出现类型错误
【发布时间】:2017-07-25 03:15:50
【问题描述】:

我从 MRI 切换到 JRuby,现在在 rails+puma 启动时遇到错误:

$ jruby -S rails s puma
TypeError: no implicit conversion of Regexp into String
   join at org/jruby/RubyArray.java:1760
  <top> at /Users/z/bin/spring:11
   load at org/jruby/RubyKernel.java:955
  <top> at /Users/z/bin/rails:3

rake 命令运行良好。

这是我的环境:

$ rvm list

rvm rubies

=* jruby-9.1.12.0 [ x86_64 ]
   ruby-2.3.3 [ x86_64 ]


# => - current
# =* - current && default
#  * - default

$ jruby -v
jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 Java HotSpot(TM) 64-Bit Server VM 25.141-b15 on 1.8.0_141-b15 +jit [darwin-x86_64]

$ gem -v
2.6.11

$ java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)

$ head Gemfile
source 'https://rubygems.org'
ruby '2.3.3', engine: 'jruby', engine_version: '9.1.12.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'active_model_serializers'
# Use Postgres as database
# gem 'pg'
# gem 'pg', '0.17.1', :platform => :jruby, :git => 'git://github.com/headius/jruby-pg.git', :branch => :master
gem 'activerecord-jdbcmysql-adapter', '~> 5.0.pre1'
gem 'puma'

想知道社区是否看到过类似的情况。我也尝试使用bundle exec rails s puma - 同样的问题。

https://stackoverflow.com/a/35352031/1445604 中提到的 RubyGems 修复没有帮助。

【问题讨论】:

    标签: ruby-on-rails jruby puma jrubyonrails


    【解决方案1】:

    不确定spring 应该在 JRuby 上做什么 - 可能不起作用,不要使用它

    gem 'activerecord-jdbcpostgresql-adapter' 也不(尚)支持 AR 5.x

    【讨论】:

    • 感谢 PG 的提示 - 我已切换到 gem 'activerecord-jdbcmysql-adapter', '~&gt; 5.0.pre1'。我不确定如何处理 spring,因为它带有 Rails。
    • 修复变得更加简单 - 我从 Gemfile 中删除了 springspring-watcher-listen 并且未污染 rails 脚​​本。
    猜你喜欢
    • 2021-01-08
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 2021-01-01
    • 2014-12-12
    • 1970-01-01
    相关资源
    最近更新 更多