jekyll-less icon indicating copy to clipboard operation
jekyll-less copied to clipboard

Error: uninitialized class variable @@mtimes

Open dagoodma opened this issue 8 years ago • 7 comments

I just installed jekyll-less, and then: gem install jekyll-less, added gem "jekyll-less" to my Gemfile, added "- jekyll-less" to _config.yml, and ran bundle update. When I try to serve the website, I see :

bundle exec jekyll serve
Configuration file: /Users/dagoodma/Documents/web/davie-goodman.com/_config.yml
Configuration file: /Users/dagoodma/Documents/web/davie-goodman.com/_config.yml
            Source: /Users/dagoodma/Documents/web/davie-goodman.com
       Destination: /Users/dagoodma/Documents/web/davie-goodman.com/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
jekyll 3.3.1 | Error:  uninitialized class variable @@mtimes in Jekyll::Less::LessCssFile
Did you mean?  mtimes

dagoodma avatar Feb 08 '17 22:02 dagoodma

This error is supposed to be fixed in pull request #14

sfi0zy avatar Feb 17 '17 08:02 sfi0zy

i added this to _plugins/jekyll-less.rb:

require "jekyll-less"
@@mtimes = {}

and this resolved it for me. hope that helps.

ebaizel avatar Mar 02 '17 22:03 ebaizel

@ebaizel I tried your suggestion, and I get a warning that looks like .../_plugins/jekyll-less.rb:2: warning: class variable access from toplevel. I'm not familiar with Ruby, but it looks like @@ signifies a class variable. In your case how can you be modifying a class variable like that when you're apparently outside of a class definition and not referring to an instance of that class? Or more importantly, any ideas how to fix my problem?

benlindsay avatar Sep 27 '18 04:09 benlindsay

@benlindsay You have to initialize this variable inside the LessCssFile class (example).

sfi0zy avatar Sep 27 '18 05:09 sfi0zy

@sfi0zy Thanks for the example! So I put ruby '2.5.1' and gem 'jekyll-less', github: 'sfi0zy/jekyll-less' in my Gemfile and

plugins:
  - "jekyll-less"

in my _config.yml, have nothing in my _plugins folder. This got rid of the uninitialized class variable @@mtimes error, but now when I try to build with a css folder that looks like this, it builds the solarized.less file just fine but won't build my style.less file, giving a bunch of errors like this:

Less Exception: variable @alert-padding is undefined
Less Exception: variable @font-size-small is undefined
Less Exception: variable @breadcrumb-padding-vertical is undefined
Less Exception: .border-right-radius is undefined
Less Exception: variable @padding-base-vertical is undefined
Less Exception: .transition is undefined
Less Exception: .opacity is undefined
Less Exception: variable @font-family-monospace is undefined
Less Exception: .transition is undefined
...

Any thoughts of what's going wrong? Thanks again for your help!

benlindsay avatar Sep 27 '18 13:09 benlindsay

@benlindsay

Any thoughts of what's going wrong?

Only one file of the bootstrap can be compiled (bootstrap.less), but Jekyll-less tries to compile every of them. The readme says:

Place .less files anywhere in your Jekyll project's directory. These will be converted to .css files with the same directory path and filename. For example, if you create a Less file at css/my-stuff/styles.less, then the corresponding css file would end up at css/my-stuff/styles.css.

In the result you see the first error for every *.less file that it can't compile. Variable "alert-padding" is undefined in alerts.less, "font-size-small" is undefined in badges.less etc. I can't reproduce these errors right now, but I think that they shouldn't affect the style.less.

sfi0zy avatar Sep 27 '18 16:09 sfi0zy

Ahh, so there's no way to, for example, just tell it to compile style.less, which imports variables from a bunch of other files? The weird thing is that it doesn't actually convert my style.less file for some reason. I just switched to this plugin and it works, so I figure I'll just stick with that. Thanks for the help!

benlindsay avatar Sep 28 '18 14:09 benlindsay