问题描述
我是红宝石的新手,我试图运行我的第一个应用程序,但是当我启动服务器时出现此错误:
Bundler Could not find compatible versions for gem "nokogiri": In Gemfile:
capybara (>= 2.15) x86-mingw32 was resolved to 3.15.1,which depends on
nokogiri (~> 1.8)
Could not find gem 'nokogiri (~> 1.8)',which is required by gem 'capybara (>= 2.15)',in any of the sources.
我尝试了许多解决方案,但都没有成功,例如,我尝试了bundle install
bundle update
bundle exec
我有红宝石版本2.3.3,
从应用程序文件夹外部运行rails -v
时使用rails版本5.1.7,但是从内部运行时出现与上述相同的错误
这是gem文件:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','~> 5.1.7'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma','~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails','~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier','>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer',platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails','~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks','~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis','~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt','~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails',group: :development
group :development,:test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug',platforms: [:mri,:mingw,:x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara','>= 2.15'
gem 'selenium-webdriver'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console','>= 3.3.0'
end
# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]```
[1]: https://i.stack.imgur.com/6sNnN.png
我跑了bundle pristine
,我得到了:
--- ERROR REPORT TEMPLATE -------------------------------------------------------
# Error Report
## Questions
Please fill out answers to these questions,it'll help us figure out
why things are going wrong.
- **What did you do?**
I ran the command `C:/RailsInstaller/Ruby2.3.3/bin/bundle pristine`
- **What did you expect to happen?**
I expected Bundler to...
- **What happened instead?**
Instead,what happened was...
- **Have you tried any solutions posted on similar issues in our issue tracker,stack overflow,or google?**
I tried...
- **Have you read our issues document,https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md?**
...
## Backtrace
NoMethodError: undefined method `specs' for nil:NilClass
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/cli/common.rb:72:in `ensure_all_gems_in_lockfile!'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/cli/pristine.rb:10:in `run'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/cli.rb:705:in `pristine'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/cli.rb:30:in `dispatch'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/cli.rb:24:in `start'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/exe/bundle:49:in `block in <top (required)>'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-2.2.0.rc.1/exe/bundle:37:in `<top (required)>'
C:/RailsInstaller/Ruby2.3.3/bin/bundle:23:in `load'
C:/RailsInstaller/Ruby2.3.3/bin/bundle:23:in `<main>'
## Environment
Bundler 2.2.0.rc.1
Platforms ruby,x86-mingw32
Ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
Full Path C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe
Config Dir C:/ProgramData
RubyGems 3.1.4
Gem Home C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0
Gem Path C:/Users/Moham/.gem/ruby/2.3.0;C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0
User Home C:/Users/Moham
User Path C:/Users/Moham/.gem/ruby/2.3.0
Bin Dir C:/RailsInstaller/Ruby2.3.3/bin
Tools
Git 2.28.0.windows.1
RVM not installed
rbenv not installed
chruby not installed
## Bundler Build Metadata
Built At 2020-07-02
Git SHA d15da3db73
Released Version true
## Gemfile
### Gemfile
ruby
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'nokogiri','~> 1.8'
# Bundle edge Rails instead: gem 'rails',:jruby]
### Gemfile.lock
<No D:/web developing/AAL/Ruby on rails/module 3/create app/my_first_app/Gemfile.lock found>
--- TEMPLATE END ----------------------------------------------------------------
Unfortunately,an unexpected error occurred,and Bundler cannot continue.
First,try this link to see if there are any existing issue reports for this error:
https://github.com/rubygems/rubygems/search?q=undefined+method+%60specs%27+for+nil+NilClass&type=Issues
If there aren't any reports for this error yet,please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
https://github.com/rubygems/rubygems/issues/new?labels=Bundler```
解决方法
请发布您的Gemfile.lock
进行确认-但这似乎水豚版本已锁定为'> = 2.15',并且Gemfile.lock中没有与之兼容的nokogiri版本。
一个快速解决方案是在您的Gemfile中将nokogiri明确设置为'nokogiri','~> 1.8'
,然后查看问题是否仍然存在。您可能需要升级水豚版本,以使其与需要它的其他宝石兼容的nokogiri版本
最后,按照以下步骤解决了问题:
- 卸载Rails安装程序并手动删除文件夹。
- 设置ruby安装程序。
- 运行
gem install rails
- 安装纱线。
- 重启电脑
- 运行
rails webpacker:install
。