ruby 新人一枚。。最近碰到一个奇怪的问题
在运行完 rails 生成器生成模型/控制器等文件后,再进入沙盒环境的 rails conosle 就会报 ruby 解释器错误:
rails g model User name:string
rails console --sandbox
#抛出错误
#上方行数太多了,terminal无法显示完全
.
.
.
.
1558 /Users/x/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb
1559 /Users/x/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console.rb
1560 /Users/x/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/console/app.rb
1561 /Users/x/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/console/helpers.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
如果运行完数据库迁移,在 rails console 里创建一个模型实例也是抛出一样的错误。
rails g model User name:string
rails db:migrate
rails console
Running via Spring preloader in process 56859
Loading development environment (Rails 5.0.0.1)
2.3.1 :001 > User.new
#抛出错误
.
.
.
1574 /Users/x/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/relation/batches.rb
1575 /Users/x/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/relation.rb
1576 /Users/x/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/associations/collection_proxy.rb
1577 /Users/x/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/association_relation.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
不确定是不是升级到 macOS10.12 造成的?我发现升级后系统自带的 ruby 版本变成了 2.3,但也有同事升级 10.12 后 ruby 版本依旧是 2.0
折腾了好久,整个 ruby 环境基本上也按站内的 wiki 重新安装了一遍,但依旧有这个问题,不知道有什么办法可以解决吗?
再不行是不是干脆全新安装一遍 macOS10.12 算了囧