Sprockets在向Heroku推送时抛出NoMethodError



我正在将我的应用程序升级到ruby 2.6.5,似乎链轮4.0.2是问题的原因。我发现的大多数答案都涉及降级到链轮3.7.2(我在本地使用(,但当在Heroku推送过程中编译资产时,我会得到以下错误:

remote:        NoMethodError: undefined method `start_with?' for #<Regexp:0x00005582ab94a790>
remote:        /tmp/build_f56a8b75/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/uri_utils.rb:78:in `valid_asset_uri?'
remote:        /tmp/build_f56a8b75/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/resolve.rb:27:in `resolve'
remote:        /tmp/build_f56a8b75/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:79:in `find_asset'
remote:        /tmp/build_f56a8b75/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
remote:        /tmp/build_f56a8b75/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'

我已将config/initializers/assets.rb修改为:

# Rails.application.config.assets.precompile << /.(?:svg|eot|woff|ttf)z/
Rails.application.config.assets.precompile << ["*.svg", "*.eot", "*.woff", "*.ttf"]

但错误仍在发生。知道怎么解决这个问题吗?

我也面临同样的错误。

由于链轮降级,我添加了以下版本指定的gem,它成功部署。

Gemfile

gem 'sprockets', '~> 3.0'

最新更新