jwhitley / requirejs-rails

RequireJS support for your Rails 3 or 4 application
MIT License
592 stars 202 forks source link

uninitialized constant Sprockets::DigestUtils in 0.9.9 #247

Open monfresh opened 9 years ago

monfresh commented 9 years ago

Hi. I just upgraded to 0.9.9 and I'm getting this error during precompilation of assets:

uninitialized constant Sprockets::DigestUtils

This is because Sprockets::DigestUtils is only available in sprockets 3.0+, but due to version restrictions from another gem in my app, I can only use sprockets 2.x.

If requirejs-rails depends on a sprockets 3.x feature, then sprockets needs to be added as a dependency with >= 3.0.

carsomyr commented 9 years ago

@monfresh Hmm, I thought this got fixed recently with Sprockets 2.x backwards compatibility.

agis commented 9 years ago

Stumbled on this too today, https://github.com/jwhitley/requirejs-rails/commit/c7babb62fe7418d23f7ae66c85a1519817c9b915 is the culprit.

@carsomyr What do you refer to by "Sprockets 2.x backwards compatibility"?

I think we would be compatible if we change the code as described here. What do you think?

monfresh commented 8 years ago

Any updates on this issue?

carsomyr commented 8 years ago

@monfresh Could you check master?

Chrisell commented 8 years ago

Also seeing this issue on 0.9.9 w/ sprockets 2.12.4. Same restriction @monfresh mentioned to being able to update sprockets.

monfresh commented 8 years ago

@carsomyr Was this supposed to be fixed in 1.0.0? I'm still seeing the same error uninitialized constant Sprockets::DigestUtils.

passabilities commented 8 years ago

@monfresh I am getting the same error. 1.0.0 was supposed to fix a precompilation error I was running into.

EDIT: So it seems that DigestUtils is only available in Rails 4. I am running into this error because my project is running Rails 3.2.22

passabilities commented 8 years ago

Ok so I found a workaround for this using Rails 3.2.22 (didnt try for any other versions) and requirejs-rails 1.0.0.

If you just copy and paste DigestUtils.rb file into config/initializers, it will attach DigestUtils into sprockets and work correctly.

NOTE: the main thing that I had to do to get it to work is change the default pack_hexdigest method from bin.unpack('H*'.freeze).first to bin.hexdigest

carsomyr commented 8 years ago

@passa763 Is there some problem with

bin.unpack('H*'.freeze).first

It seems to work for me.

carsomyr commented 8 years ago

Can y'all test the commit above? @monfresh @passa763 @Chrisell

passabilities commented 8 years ago

@carsomyr bin needs to be a string in order for unpack to work. But for me, bin is a <Digest::MD5> object.

EDIT: what Rails version are you using?

carsomyr commented 8 years ago

All, I'm working on a solution that everyone can use. Apparently there are some version inconsistencies to sort through as to which methods are and aren't available for use.

fregas commented 8 years ago

I'm having this issue with rails 4.0.13 and requirejs-rails 1.0. I also tried requirejs master. Same problem.

dhara-pyrumas commented 7 years ago

I'm using Rails 4.2.4 and requirejs-rails 1.0.0. Getting same error, please help!

carsomyr commented 7 years ago

Does using master help?

dhara-pyrumas commented 7 years ago

I commented both sprockets and sprockets-rails, but when I run the command,

gem list | grep sprocket

o/p is, sprockets (3.7.1, 2.12.4) sprockets-rails (3.2.0, 2.1.4)

After commenting gems, I'm now able to run assets:precompile.