uninitialized constant CssParser::VERSION
kenn opened this issue · 7 comments
I have the following error after upgrading from 1.2.6 to 1.3.2
> require 'css_parser'
NameError: uninitialized constant CssParser::VERSION
If I understand autoload correctly, it looks like require 'css_parser'
is no longer necessary. It will eagerly load the first time it is initialized. Did you try that out?
Also, this is a breaking change with roadie as a gem version is not explicitly set.
I did it from irb - how can I load the library without require 'css_parser'
? The README suggests that, too.
$ irb
2.0.0p0 :001 > require 'css_parser'
NameError: uninitialized constant CssParser::VERSION
...
Same here. The issue is with gemspec version requirement. Why not require a version like this:
require File.expand_path('../lib/css_parser/version', __FILE__)
Here's the full trace: it seems that css_parser.rb:12
tries to run require 'css_parser/parser'
, then parser.rb:17
tries to evaluate CssParser::VERSION
for USER_AGENT
, but it doesn't work because autoload :VERSION
isn't processed yet.
NameError: uninitialized constant CssParser::VERSION
from ~/.rvm/gems/ruby-2.0.0-p0/gems/css_parser-1.3.2/lib/css_parser/parser.rb:17:in `<class:Parser>'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/css_parser-1.3.2/lib/css_parser/parser.rb:16:in `<module:CssParser>'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/css_parser-1.3.2/lib/css_parser/parser.rb:1:in `<top (required)>'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/css_parser-1.3.2/lib/css_parser.rb:12:in `<top (required)>'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
from (irb):1
from ~/.rvm/rubies/ruby-2.0.0-p0/bin/irb:16:in `<main>'
I'm finding the same error when require 'css_parser' (1.3.2) is called from premailer-1.7.3/lib/premailer.rb:5
When I checkout css_parser locally and include with
gem 'css_parser', :path => '/home/steve/rails/css_parser'
Then it works fine.
I wonder if autoload is only registering in development mode or something?
Worked around this issue in 1.3.3 for now. We will follow up with projects that do not depend on an explicit version and give the gem an overhaul to clean some of these deps up.