-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.0 error undefined method start_with? #632
Comments
Hello, please follow the issue template, without an example app there's not a very large chance that i'll be able to help.
|
@jason-hobbs you probably have a pattern like this somewhere in your code base
@schneems is that something that suppose to work in the first place? |
In general we're pushing people to move to the manifest.js https://schneems.com/2017/11/22/self-hosted-config-introducing-the-sprockets-manifestjs/ . I don't have a more concrete answer here. I looked in the code and I don't see where we would be calling a proc with 4.0 so I'm assuming it's removal was intentional. I do know that |
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 LOOSE_APP_ASSETS = lambda do |logical_path, filename|
filename.start_with?(::Rails.root.join('app/assets').to_s) &&
!['.js', '.css', ''].include?(File.extname(logical_path))
end
config.assets.precompile = [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(.css|js)$/] 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: // app/assets/config/manifest.js
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link my_engine
// my_engine/app/assets/config/my_engine.js
//= link_tree ../images/bootstrap 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. |
Okay, so here's the integration point with Sprockets and sprockets-rails @precompiled_assets ||= assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set The precompile array gets passed into the sprockets/lib/sprockets/manifest.rb Lines 121 to 150 in 4174470
It uses a lot of files in the legacy file https://github.com/rails/sprockets/blob/3.x/lib/sprockets/legacy.rb If there's an interface people are using that is not supported in 4.0 then we need to deprecate it and cut a release of 3.x so at least some people get a little heads up. I'm still not sure exactly where the proc support exists. |
I don't have a proc (that I know of) related to assets, and I've been getting the same error while trying to port our Sprockets 3.x setup to 4.0. I'm looking into a smaller, reproducible test case. We're running Rails 6.0.0. |
I suspect that in our case this might come from ActiveAdmin: |
I have nothing like that in my app. |
Here is more of the error:
|
I'm getting same error on Rails 6, Rails 5 is fine.
|
this might help you to investigate rails c
Rails.application.config.assets.precompile.select{ |path| path.is_a?(Proc) }
=> [#<Proc:0x000000000c320198@/source/init.rb:78>] it's an error since 8c8cccf#diff-56b8a4f4a3946e2ca1750c8580181925L24 |
@ahorek this was super-helpful. Our instances of this came from PGHero and Searchjoy, not from ActiveAdmin as I had suspected. |
I just updated the blazer gem in my app to 2.2.1 and it fixed this issue! |
It sounds like proc support was definitively removed, though i'm still not quite sure where. We should add a deprecation in 3.x for this. I'm assuming that regex support was also removed. Surprised we didn't catch this earlier since we've been in beta since 2016. |
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 Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/ I have now replaced it with the following which fixed the issue for me: Rails.application.config.assets.precompile << ["*.svg", "*.eot", "*.woff", "*.ttf"] |
Downgraded gem
|
I am getting this error when when I'm trying to call I added line above to make ActiveAdmin work with ActionText. The development environment it goes well, but in production I'm getting error. # config/initializers/active_admin.rb
config.register_javascript Webpacker.manifest.lookup('action_text.js') Error that I got:
This happened due I have no assets compiled yet when this code ran, so |
@majksner Did you resolve your problem? I'm currently having the same problem. |
@Kani999 You have to check 3rd party gems. Some of those are culprit. Check #632 (comment) |
@majksner Thanks for the tip, but only thing related to mine problem I can found is Regexp |
I had the same problem here (related to bootstrap). Installing BootstrapI was following the installation guide available in the blog below: 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 ( By downgrading the specific ruby gem ( Enviroment
Error
SolutionDowngrade your Add the following line to the
Then, run the following commands:
|
so rails now is not working with sprockets@4? |
[osboxes@osboxes exec-central]$ bundle exec rake assets:precompile --trace |
an error: NoMethodError: undefined method `start_with?' for <Proc:0x0000563a058a7330> when trying to push to staging Going off of this comment: rails/sprockets#632 (comment)
downgraded to gem 'sprockets', '~> 3.7.2' fix the issue for me. Thanks @europ |
1 similar comment
downgraded to gem 'sprockets', '~> 3.7.2' fix the issue for me. Thanks @europ |
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
The text was updated successfully, but these errors were encountered: