deprecation warning at 'rails s'
coppolaf opened this issue · comments
guys,
when i start app in development mode i receive this deprecation warnings
actually all seems to run fine, but not production deployment tests have been done yet!!
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
(called from block in <class:Railtie> at /home/francesco/.rvm/gems/ruby-2.2.2@crm_2016/bundler/gems/less-rails-05186ebeea3a/lib/less/rails/railtie.rb:16)
DEPRECATION WARNING: You are using the a deprecated processor interface Less::Rails::ImportProcessor.
Please update your processor interface:
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
(called from block in <class:Railtie> at /home/francesco/.rvm/gems/ruby-2.2.2@crm_2016/bundler/gems/less-rails-05186ebeea3a/lib/less/rails/railtie.rb:21)
[2016-07-22 11:24:33] INFO WEBrick 1.3.1
[2016-07-22 11:24:33] INFO ruby 2.2.2 (2015-04-13) [x86_64-linux]
[2016-07-22 11:24:33] INFO WEBrick::HTTPServer#start: pid=22380 port=3000
i think something is running bad during initialization against sprocket v.3.7.0...
available to give you more info if needed....
waiting your suggestions
regards
francesco
Same problem already solved on sass-rails gem: rails/sass-rails#381
Diff: rails/sass-rails@v5.0.5...v5.0.6
✌️
+1
i've seen simi has self-assigned this issue..
supposing he's working on....
i'll remain available for any other info may be useful!
bye,
francesco
Yup, I'm fighting Rails 5 support removing this deprecation message in https://github.com/metaskills/less-rails/tree/rails5 branch. Not ready yet.
thank you for your time!!!
waiting!!
bye
francesco
+1
Just to help others, I'm using the branch rails5 and still get the warnings:
DEPRECATION WARNING: Sprockets method
register_engineis deprecated. Please register a mime type using
register_mime_typethen use
register_compressoror
register_transformer. https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors (called from block in <class:Railtie> at /Users/felipero/.rvm/gems/ruby-2.3.1@and1analytics/bundler/gems/less-rails-2b251787fc69/lib/less/rails/railtie.rb:16) DEPRECATION WARNING: You are using the a deprecated processor interface Less::Rails::ImportProcessor. Please update your processor interface: https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors (called from block in <class:Railtie> at /Users/felipero/.rvm/gems/ruby-2.3.1@and1analytics/bundler/gems/less-rails-2b251787fc69/lib/less/rails/railtie.rb:21)
Any update on this one @simi ?
+1
I have something prepared. But I can't reach all Sprockets compatibility. I think new version dropping older version of Sprockets will be easy way how to solve this, but it will force users to update Sprockets for older rails. I'm still thinking how to solve this.
Any ideas?
I'll try something this weekend if my family duties will permit....
Not sure to be able but i'll try and keep you updated!!!
Regards
Francesco
PS: May you give me a preview of your changes into init routine?!?
This May sure be helpful!!
@coppolaf it is in rails5 branch. Latest commit is WIP. I'll probably need to study Sprockets to be able to rewrite LessTemplate
to use new Sprockets API instead of Tilt template API.
Ok...
I'll try to look at your code...
Bye
Francesco
Il 26/ago/2016 09:54 PM, "Josef Šimánek" notifications@github.com ha
scritto:
@coppolaf https://github.com/coppolaf it is in rails5 branch. Latest
commit is WIP. I'll probably need to study Sprockets to be able to rewrite
LessTemplate to use new Sprockets API instead of Tilt template API.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#122 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG_wheeojRiIYJnwaxt4zWmSjdnFBTqFks5qj0RygaJpZM4JSl3Z
.
Josef,
done some testing....
using 'raw' your code, i receive an error (see:
#123)
the pull request author (manzikhov) has revealed the same issue and
proposed a fix for it...
here you'll find my version,
feel free to choose the one you evaluate more flexible (extracted from
railtie.rb):
unable to actually find solution to the second deprecation warning....
bye
francesco
On 26/08/2016 21:54, Josef Šimánek wrote:
@coppolaf https://github.com/coppolaf it is in rails5 branch. Latest
commit is WIP. I'll probably need to study Sprockets to be able to
rewrite |LessTemplate| to use new Sprockets API instead of Tilt
template API.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#122 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG_wheeojRiIYJnwaxt4zWmSjdnFBTqFks5qj0RygaJpZM4JSl3Z.
Thanks a lot! I'll inspect this tomorrow and let you know.
Ok...
Keep me updated!!
Good night!!
F.
Il 30/ago/2016 11:09 PM, "Josef Šimánek" notifications@github.com ha
scritto:
Thanks a lot! I'll inspect this tomorrow and let you know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#122 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG_whWD-WBlPUnV-GwUN64cNoo1jo48xks5qlJv7gaJpZM4JSl3Z
.
Josef,
Have you inspected my code?!
I think i've omitted the rspec related part so it will fail testing
phase... Actually using my modded version in my development env (other
app!!) Waiting your definitive release!!
Pls let me know your opinion about the solution i've applied to solve the
first deprecation warning!!
Waiting news...
Regards
Francesco
Il 30/ago/2016 11:09 PM, "Josef Šimánek" notifications@github.com ha
scritto:
Thanks a lot! I'll inspect this tomorrow and let you know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#122 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG_whWD-WBlPUnV-GwUN64cNoo1jo48xks5qlJv7gaJpZM4JSl3Z
.
Damn, I totally forgot about this. I'm really busy right now, but I'll do my best to take a look A$AP.
maybe @maxd is around
No problem... As i said i've not implementeranno any testing so build test
by travis-ci will fail!!!
Waiting news!!
Regards
Francesco
Il 08/set/2016 12:47 PM, "Josef Šimánek" notifications@github.com ha
scritto:
Damn, I totally forgot about this. I'm really busy right now, but I'll do
my best to take a look A$AP.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#122 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG_whaWcSVkqdxYepAlT98QlT0IY9jeyks5qn-e7gaJpZM4JSl3Z
.
What is the status of this? I have this issue too.
Thanks
Carol
Is this issue solved?
Why it's so hard to fix? Something strange =\
For the time being, the issue is avoided by adding gem "sprockets", '3.6.3'
to Gemfile.
still a thing.
gem "sprockets", '3.6.3'
fixed the problem, but if you use 3.7
the same problem occurs.
@simi, I created a pull request for solving the problem here: https://github.com/MustafaZain/less-rails
until rewrite LessTemplate with Sprockets API instead of Tilt template API.
@krtschmr @yohm @USvER @poombavai @dawcars @coppolaf
You can use this in the Gemfile until the pull request is merged or rewriting LessTemplate with Sprockets API
gem 'less-rails', git: 'https://github.com/MustafaZain/less-rails'
Bootstrap users: currently less-rails-bootstrap requires <= 2.8
https://github.com/metaskills/less-rails-bootstrap/blob/master/less-rails-bootstrap.gemspec#L18
This means probably a fork of that is necessary as well, until @metaskills has a chance to review all these version number changes and clean it all up in his master.
Ok, I branched it here https://github.com/Genkilabs/less-rails-bootstrap/tree/v3.3.5.1
I'll try it out and make a PR to match the 2.8.1 ver bump by @MustafaZain
--- edit
It turns out changing less-rails-bootstrap was not necessary as @nonrational had already extended @MustafaZain work. However in order to be compatible with both Sprockets 3 and 4, for people transitioning, the ImportProcessor still needs to respond to call(arg)
so I stubbed in a blank method. Find it here if you like: https://github.com/Genkilabs/less-rails
This let me run less-rails-bootstrap on sprockets 3.7 (currently master) without deprecation, in prep for sprockets 4.
gem 'less-rails', git: 'https://github.com/Genkilabs/less-rails' #fix for deprecated Sprockets ImportProcessor
gem 'less-rails-bootstrap'
--- further edit
I take it all back!
My branch does not work for people wanting to support all kinds of sprockets.
The issue is that less-rails is built on Tilt and the ImportProcessor on Tilt::Template. Unfortunately this was written using the Sprockets 2 "render" syntax
https://github.com/rtomayko/tilt/blob/master/lib/tilt/template.rb#L98
So the real solution is to properly support a request to the class method "call".
Genkilabs: FWIW, in rails 5 this got rid of my 'register_engine' deprecation warnings but not the ImportProcessor warnings. Thanks for your help so far...
@patrickkidd I used the fix from @MustafaZain ( https://github.com/MustafaZain/less-rails ) & read it to hand patch both issues out.
I use Rails 4.2.8 for my project with less-rails gem. And i got message:
DEPRECATION WARNING: You are using the a deprecated processor interface Less::Rails::ImportProcessor.
Please update your processor interface:
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
(called from block (2 levels) in <class:Railtie> at /home/thiensubs/.rvm/gems/ruby-2.3.1/bundler/gems/less-rails-7407431b8ae5/lib/less/rails/railtie.rb:32)
Can you help me how to resolve this message?
@thiensubs Check the previous comment as a temp solution: #122 (comment)
This is @MustafaZain's PR: #128
Anytime soon?
Hi everyone, just wondering if you could test this fork to see if it fixes your deprecation errors: https://github.com/brendon/less-rails/tree/fix-sprockets-loading. It should support Sprockets 2, 3, and 4 though looking at the .gemspec
it looks like it's currently locked to 3.x.
@brendon I can confirm that this fix completely removes the warnings for me.
@brendon upon further investigation, I've found that running my application with less-rails pointing to your fork results in a slew of parser errors. I have not had an opportunity to figure out why but I thought you might want to be alerted.
Thanks @tmking. That's interesting. If you could give me some more details that would be helpful.
@brendon what happened was that the majority of my feature specs threw a Less::ParserError because of an undefined variable. Other specs failed because of a Sprockets::FileNotFound exception. The app threw the same Less::ParseError exception when accessed normally in the browser.
I briefly looked into upgrading libv8 to a more recent version but my app also uses therubyracer, which has a dependency on libv8 ~> 3.16.14.15. I did confirm that everything works as expected when the gem is pointed to the master branch.
By the way, the app is running on Rails 4.2.7 and Ruby 2.2.5.
Yes that's strange. Can you grab my fork and branch locally then try removing the Grease
wrapper around the Template
and Processor
. Try one at a time. Grease.apply(LessTemplate)
.
Use the local copy in your app and see if it stops failing at any point. You'll probably still get the deprecation warnings but hopefully we can track down which exact change is causing problems.
@brendon I think the issue is that the variable is defined in a .less.erb file. It looks like a separate transformer needs to be registered for processing erb.
Ah yes, I think the reason for tilt
was so that all the various use cases would be handled automatically. I think in Sprockets 3/4 we need to say what we support explicitly. I'll look into this some more. Can people ping in with what they use with less? I'd assume probably only erb
?
Ok, I've added .less.erb
as a mime type and changed to use register_transformer
instead of preprocessor
. Can you let me know how that works for you? I've updated the branch. @simi, I'd really appreciate it if you could chime in at this point as to the possibility of this being merged. :)
Hey, guys. Here is my code to solve the "deprecated processor interface Less::Rails::ImportProcessor" warning.
For my case,
sprockets (3.7.1)
Rails (5.0.2)
CODE IS BELOW
module Less
module Rails
class ImportProcessor < Tilt::Template
IMPORT_SCANNER = /@import\s*['"]([^'"]+)['"]\s*;/.freeze
PATHNAME_FINDER = Proc.new { |scope, path|
begin
scope.resolve(path)
rescue Sprockets::FileNotFound
nil
end
}
def prepare
end
def evaluate(scope, locals, &block)
self.class.depend_on scope, data
data
end
def self.call(input)
scope = Sprockets::Context.new(input)
data = input[:data]
self.depend_on scope, data
end
def self.depend_on(scope, data, base=File.dirname(scope.logical_path))
import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq
import_paths.each do |path|
pathname = PATHNAME_FINDER.call(scope, path) || PATHNAME_FINDER.call(scope, File.join(base, path))
scope.depend_on(pathname) if pathname && pathname.to_s.ends_with?('.less')
self.depend_on(scope, File.read(pathname), File.dirname(path)) if pathname
end
data
end
end
end
end
You should do monkey patch, whatever. or see use https://github.com/jyfcrw/less-rails
@brendon that change worked for me. All my specs are passing now and the deprecation warnings are gone.
Not sure about the history of the project but this is @metaskills ' repo, right? Maybe he can merge?
Hello. Sorry for lack of my response.
Is there any patch solving this deprecation for all supported Sprockets versions?
Or maybe we can drop old Sprockets support. I'm not sure how to proceed here.
Hi @simi, please check out this PR: #137. It solves the deprecation for versions 2 and 3. Version 4 of sprockets hasn't actually be released yet. The test suite currently fails on 4beta but it more because of changes to the manifest logic and accessing assets for testing purposes. Someone here has reported it works with sprockets 4 in a project I think. My PR supports both the old and new sprockets methods.
I've been following this for the past 6 months. Can I do anything to help?
Unfortunately, it all rests on @simi now to review my PR and hopefully accept it. You could try using my fork to see if everything works correctly for you (css code is generated correctly etc...) in the meantime.
@brendon nice work. I left few comments in your PR. I'm ready to merge and release and to finally close this issue.
@StanBoyet I'm sorry, but I had no time to fix this (I tried 3 times already) and I was waiting for PR aiming on both 2 and 3 Sprockets version.
@simi I don't add anything to the conversation but I'd like to add: don't get me wrong, I'm really grateful for your work and all the contributors. I don't like coming in here without bringing anything to the table, hence the proposition to help.
Glad to see an end to it though. Thanks again ;-)