jwhitley/requirejs-rails

uninitialized constant Sprockets::DigestUtils in 0.9.9

Opened this issue · 16 comments

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.

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

agis commented

Stumbled on this too today, c7babb6 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?

Any updates on this issue?

@monfresh Could you check master?

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

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

@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

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

@passa763 Is there some problem with

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

It seems to work for me.

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

@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?

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.

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

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

Does using master help?

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.