ruby-on-rails - 缺少 nokogiri gemspec 时出现 Rails 控制台错误,但 nokogiri 没有 gemspec
问题描述
我尝试通过 RVM 重新安装 Ruby 2.3.6 以修复一些错误,我必须明确指定 OpenSSL 路径才能重新安装。安装 bundler 并bundle install
在我的项目目录中运行后,我尝试运行rails c
and bundle exec rails c
,但出现此错误:
/Users/abhaskar/.rvm/gems/ruby-2.3.6@px-core/gems/bundler-1.16.1/lib/bundler/stub_specification.rb:97:in `_remote_specification': The gemspec for nokogiri-1.10.1 at /Users/abhaskar/.rvm/gems/ruby-2.3.6@px-core/specifications/nokogiri-1.10.1.gemspec was missing or broken. Try running `gem pristine nokogiri -v 1.10.1` to fix the cached spec. (Bundler::GemspecError)
然而,Nokogiri 没有 gemspec,运行建议的gem pristine
命令并没有改变任何东西。我检查了 Nokogiri 是否列在我的 Gemfile 中。我的团队成员都没有面临同样的问题。如何诊断和解决此问题?
更新:bundle exec gem pristine nokogiri -v 1.10.1
错误:
ERROR: While executing gem ... (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
current directory: /Users/abhaskar/.rvm/gems/ruby-2.3.6/gems/nokogiri-1.10.1/ext/nokogiri
/Users/abhaskar/.rvm/rubies/ruby-2.3.6/bin/ruby -r ./siteconf20190130-46592-q2jdnm.rb extconf.rb
/Users/abhaskar/.rvm/rubies/ruby-2.3.6/lib/ruby/site_ruby/2.3.0/bundler/spec_set.rb:91:in `block in materialize': Could not find nokogiri-1.10.1 in any of the sources (Bundler::GemNotFound)
解决方案
这是我的强烈建议:保释 rvm 并转移到 docker。你每次都得到一个干净的构建。不用担心在不同项目之间混合系统库。等等
了解 docker 有一点开销,但是一旦你这样做了,你就可以自由地运行任何版本的 postgres/mysql/rails/ruby/whatever 并随意混合和匹配。
推荐阅读
- python - 预计哪些 numpy 结构作为使用 numpy.char 函数的输入?
- cplex - 变量作为索引?CPLEX
- database - 无法将数据添加到我的数据库 PSQL,关系“table_name”的列“column_name”不存在
- docker - 如何诊断在 docker-compose 上本地运行的 Docker 映像,但当我从已发布的注册表中将其拉下时不
- yarnpkg - AWS CodeBuild 不适用于 Yarn 工作区
- c# - REST API 在 C# 中不接受多个参数
- functional-programming - 方案将列表定义为局部变量
- python - 是否可以将变量作为 CSS 类传递给 Django html 模板?
- javascript - 错误类型错误:无法读取未定义的属性“val”
- java - 错误:仅引导加载程序类支持共享,因为已附加引导类路径