Error installing nokogiri in a Ruby on Rails application?
nokogiri is a Ruby "gem" (library) for parsing XML and HTML.
Your Rails project should have a Gemfile which specifies the name and version of each gem needed to run the project. To install the gems listed in the gemfile:
bundle install
After that install completes successfully, Rails should be able to find the nokogiri gem.
Error installing Nokogiri gem
I fixed the problem by first using brew install libxml2 libxslt
. I then had to download the old xcode-select developer tools from late October found here https://developer.apple.com/downloads/index.action#
After that, running sudo gem install nokogiri
finally worked.
Nokogiri raises error when parsing html with meta charset='UTF-8
Nokogiri is primarily an XML parser and thus expects mostly valid XML. Although HTML looks a lot like XML, especially with HTML 5, there are different rules about e.g. closing tags and algorithms to detect things such as encoding which makes HTML 5 incompatible to XML and XML parsers.
In an issue related to your problem, the response of Mike Dalessio (one of the nokogiri maintainers) was accordingly:
Nokogiri does not support HTML5. You may want to check out the Nokogumbo project, which aims for HTML5 compatibility with the Gumbo parser.
how to fix : Bundler could not find compatible versions for gem nokogiri
Finally the problem was solved following these steps:
- uninstall rails installer and remove the folder manually.
- setup ruby installer.
- run
gem install rails
- install yarn.
- restart pc
- run
rails webpacker:install
.
Related Topics
Comparing Identical Datetime Objects in Ruby -- Why Are These Two Datetime.Now's Not Equal
How to Mock an Instance Method of an Already Mocked Object
Using Ruby, What Is the Most Efficient Way to Get the Content Type of a Given Url
Is the Current Ruby Method Called via Super
Why Is the Splat Used Inside an Array Definition Here
Fast-Stemmer Installation Problems
Cocoapods Folder Does Not Exist/Permissions Error
Creating a Gmail Draft with Recipients Through Gmail API
How to Programmatically Convert Mp3 to an Itunes-Playable Aac/M4A File
How to Access Current_User Object in Model
Selenium2 Webdriver Ruby => How Click on a Hidden Link
Activerecord User-Supplied Column Name
Respond_With Redirect with Notice Flash Message Not Working
Word Document.Saveas Ignores Encoding, When Calling Through Ole, from Ruby or Vbs
How to Add Conditional Rubygem Requirements to a Gem Specification