sprockets: 4.0 error undefined method start_with?
When I run rspec or rails server with sprockets updated to 4.0 I get:
undefined method start_with?' for #<Proc:0x00007ffeadf32740> # /Users/jasonhobbs/.rvm/gems/ruby-2.6.5/gems/sprockets-4.0.0/lib/sprockets/uri_utils.rb:78:in
valid_asset_uri?’
I have no idea what this is referring to in my code. I had no issues with sprockets 3.7.2
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (7 by maintainers)
Links to this issue
Commits related to this issue
- updated formatting for sprockets v4 https://github.com/rails/sprockets/issues/632#issuecomment-551324428 — committed to tb582/staytus by deleted user 4 years ago
- downgrad sprockets to prevent: https://github.com/rails/sprockets/issues/632 — committed to Flo3719/EatViet by Flo3719 3 years ago
- Attempting to adjust the precompile (for production) as we were getting an error: NoMethodError: undefined method `start_with?' for <Proc:0x0000563a058a7330> when trying to push to staging Going off ... — committed to bluelabsio/medicaid_eligibility by archetypalsxe 2 years ago
Just wanted to chime in and let you know that I ran into this same issue when using regexes. I think I found an article somewhere explaining how to add webfonts to the asset pipeline by adding this code to
config/initializers/assets.rb
I have now replaced it with the following which fixed the issue for me:
Downgraded gem
sprockets
from4.0.0
to3.7.2
this might help you to investigate
it’s an error since https://github.com/rails/sprockets/commit/8c8cccf0f554299f8be85a0b8b2fe4bc23732b4f#diff-56b8a4f4a3946e2ca1750c8580181925L24
I had the same problem here (related to bootstrap).
Installing Bootstrap
I was following the installation guide available in the blog below: https://www.timdisab.com/installing-bootstrap-4-on-rails-6/
Then, I also tried to install the bootstrap using the following ruby bootstrap gems:
via command below:
I got the same error
After all, it was not working due to an incorrect gem (
sprockets
) version.By downgrading the specific ruby gem (
sprockets
), the bootstrap was successfully added to my rails-6 project.Enviroment
Error
Solution
Downgrade your
sprockets
gem in yourGemfile
as it was suggested by @cassiopagnoncelli in https://github.com/rails/sprockets/issues/632#issuecomment-559861344Add the following line to the
Gemfile
:Then, run the following commands:
I just updated the blazer gem in my app to 2.2.1 and it fixed this issue!
I’m getting same error on Rails 6, Rails 5 is fine.
Okay in our docs “How Sprockets Work” talk from Rafael. I think this is intentional, but I don’t know why we didn’t deprecate the interface first.
Sprockets has special support for
Procs
on the precompilation. Before, in Sprockets version 3, we had this code that is telling us to precompile all the known JavaScript and stylesheet files in the app directory.As you can see, the code above is not easy to understand, so in Sprockets version 4, we have a new syntax for that shown below:
It’s called the link directive, so it’s easier to understand what’s going on there. You can actually see that all the images in the image directory is going to be precompiled just as the JavaScript and the style sheets do. One can use this directive to compose new libraries. I have that link to my engine that’s also defining its own manifest file. It’s now easy to understand and to compose. Not that we are going to remove the precompile list, but these new directives are there to help to build the precompile list. We have all these directives by default in Sprockets and later we will explain how you can extend the directives to create your own.
@Kani999 You have to check 3rd party gems. Some of those are culprit. Check https://github.com/rails/sprockets/issues/632#issuecomment-540032759
@ahorek this was super-helpful. Our instances of this came from PGHero and Searchjoy, not from ActiveAdmin as I had suspected.