requirejs-rails icon indicating copy to clipboard operation
requirejs-rails copied to clipboard

uninitialized constant Sprockets::DigestUtils in 0.9.9

Open monfresh opened this issue 10 years ago • 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 avatar Aug 15 '15 13:08 monfresh

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

carsomyr avatar Aug 16 '15 20:08 carsomyr

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?

agis avatar Aug 18 '15 13:08 agis

Any updates on this issue?

monfresh avatar Nov 28 '15 03:11 monfresh

@monfresh Could you check master?

carsomyr avatar Nov 28 '15 03:11 carsomyr

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

Chrisell avatar Dec 01 '15 19:12 Chrisell

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

monfresh avatar Dec 26 '15 20:12 monfresh

@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 avatar Dec 27 '15 04:12 passabilities

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

passabilities avatar Dec 30 '15 02:12 passabilities

@passa763 Is there some problem with

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

It seems to work for me.

carsomyr avatar Dec 31 '15 02:12 carsomyr

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

carsomyr avatar Dec 31 '15 02:12 carsomyr

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

passabilities avatar Dec 31 '15 04:12 passabilities

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.

carsomyr avatar Jan 07 '16 00:01 carsomyr

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

fregas avatar Apr 21 '16 19:04 fregas

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

dhara-pyrumas avatar Jul 25 '17 06:07 dhara-pyrumas

Does using master help?

carsomyr avatar Jul 25 '17 06:07 carsomyr

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.

dhara-pyrumas avatar Jul 25 '17 06:07 dhara-pyrumas