Upgrading to Rails 4.2 issues
Asked Answered
G

3

6

I'm trying to upgrade to Rails 4.2 from Rails 4.1.9 and when I attempt to run the console or the server i get the following error. Any thoughts? I thought the html-scanner gem was included with Action::View

gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- action_view/vendor/html-scanner (LoadError)
Gorgeous answered 15/1, 2015 at 19:3 Comment(2)
Ruby 2.2.0 and it has been bundled.Gorgeous
It looks like like it's an incompatibility with some of my gems. In this case prototype-rails.Gorgeous
R
10

The OP's issue (and mine) was to do with an incompatibility in the prototype-rails gem. This can be fixed by using the "4.2" branch of prototype-rails directly from github. Modify your Gemfile entry as follows:

gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2'

Note that the prototype-rails gem will not be supported from Rails 5 onwards, so now would be as good a time as any to remove this dependency.

Resplendence answered 7/4, 2015 at 5:47 Comment(0)
R
3

I believe they removed html-scanner from rails in 4.2 when they switched to rails-html-sanitizer according to the upgrade guide but it seems you can use the rails-deprecated_sanitizer gem to your Gemfile to then re-include the html-scanner library

gem 'rails-deprecated_sanitizer'

Hope this helps!

Retrad answered 16/1, 2015 at 1:53 Comment(3)
I tried adding that gem at one point and it still didn't work. I'll try it again.Gorgeous
This isn't the correct answer per say but it's close if folks need to use the old sanitizer. The issue in particular was some outdated gems.Gorgeous
It worked for me, however, I had to install the gem manually using gem install rails-deprecated_sanitizer, it did not work when I added it to Gemfile and did bundle installEctomy
D
1

I've also had this problem on a legacy project. It's a bundler 1.17.3 / ruby 2.4 / rails 4.2.11.3 and it was driving me up the wall.

The following nasty hack worked:

Gemfile:

gem 'rails-deprecated_sanitizer'
gem 'prototype-rails', git: 'https://github.com/rails/prototype-rails.git', branch: '4.2'

but that wasn't enough. I then had to get rails-deprecated_sanitizer to appear where the gems wanted it.

So in my project, I created lib/action_view/vendor/html-scanner.rb:

require 'rails-deprecated_sanitizer'
require 'rails/deprecated_sanitizer/railtie'
require 'rails/deprecated_sanitizer/html-scanner'

(I doubt all three are needed, mind)

This depends on lib being in your load paths of course.

That fixed the problem, and I was finally able to reset the db and launch the server.

Doctrinal answered 25/5, 2020 at 14:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.