I’m new to ruby, I was trying to run my first app but when I start the server I get this error:
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.
I’ve tried many solutions and none worked, for example I tried bundle install
bundle update
bundle exec
I have ruby version 2.3.3,
rails version 5.1.7 when I run rails -v
from outside the app folder, but from inside I get the same error as above
here is the gem file:
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
I ran bundle pristine
and I got this:
--- 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', 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]
### 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```
2
Answers
Finally the problem was solved following these steps:
gem install rails
rails webpacker:install
.Please post your
Gemfile.lock
to confirm – but this looks like the capybara version is locked to ‘>=2.15’ and the nokogiri version compatible with it is not present in the Gemfile.lock.A quick fix is to set nokogiri to
'nokogiri', '~> 1.8'
explicitly in your Gemfile and see if the issue still persists. You might want to upgrade your capybara version to match a nokogiri version that’s compatible with the other gems that require it