安装Active Admin时报superclass mismatch for class StringIO (TypeError)错误
问题根因
superclass mismatch for class StringIO (TypeError)报错由 Ruby 2.5.8 与 bootsnap 1.9.1 版本不兼容 触发,同时可能伴随 Active Admin 版本与当前 Ruby/Rails 版本不匹配、权限组件重复引入的问题。
解决步骤
- 先处理重复依赖问题:Gemfile 中不需要同时引入 cancancan 和 pundit 两个权限依赖,删除不需要的一个后执行
bundle install。 - 降级 bootsnap 到兼容 Ruby 2.5 的版本:修改 Gemfile 中 bootsnap 的声明为
执行gem 'bootsnap', '<= 1.8.1', require: falsebundle update bootsnap完成版本更新。 - 匹配 Active Admin 版本:如果你的 Rails 版本为 5.2 系列(对应 Ruby 2.5.x 版本),在 Gemfile 中指定 Active Admin 版本约束
执行gem 'activeadmin', '~> 2.9'bundle update activeadmin更新。 - 重新执行安装命令:
执行完成后运行rails g active_admin:installrails db:migrate完成数据库迁移即可。
内容的提问来源于stack exchange,提问作者Hamza Jamal
相关产品推荐
相关产品推荐

