Skip to content
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

Move rouge loading #2189

Merged
merged 1 commit into from Apr 3, 2014

Conversation

Projects
None yet
4 participants
@benhanzl
Copy link
Contributor

benhanzl commented Apr 1, 2014

When generating a new site with 2.0.0.alpha.2, I get the following error:

$ jekyll new benhanzl.com
/Users/benhanzl/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rouge (LoadError)
    from /Users/benhanzl/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll/converters/markdown/redcarpet_parser.rb:42:in `<module:WithRouge>'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll/converters/markdown/redcarpet_parser.rb:41:in `<class:RedcarpetParser>'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll/converters/markdown/redcarpet_parser.rb:4:in `<class:Markdown>'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll/converters/markdown/redcarpet_parser.rb:3:in `<module:Converters>'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll/converters/markdown/redcarpet_parser.rb:2:in `<module:Jekyll>'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll/converters/markdown/redcarpet_parser.rb:1:in `<top (required)>'
    from /Users/benhanzl/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/benhanzl/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll.rb:11:in `block in require_all'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll.rb:10:in `each'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll.rb:10:in `require_all'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/lib/jekyll.rb:61:in `<top (required)>'
    from /Users/benhanzl/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/benhanzl/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/gems/jekyll-2.0.0.alpha.2/bin/jekyll:6:in `<top (required)>'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/bin/jekyll:23:in `load'
    from /Users/benhanzl/.rvm/gems/ruby-2.1.1@benhanzl/bin/jekyll:23:in `<main>'

This is caused because rouge is being required regardless of whether or not it is being used. I moved the require to when the renderer is setup.

I believe this relates to #2079.

@@ -77,6 +67,15 @@ def initialize(config)
end
when 'rouge'
Class.new(Redcarpet::Render::HTML) do
require 'rouge'
require 'rouge/plugins/redcarpet'

This comment has been minimized.

@parkr

parkr Apr 1, 2014

Member

So this is run at runtime rather than interpret-time?

This comment has been minimized.

@benhanzl

benhanzl Apr 1, 2014

Author Contributor

Correct.

@parkr

This comment has been minimized.

Copy link
Member

parkr commented Apr 1, 2014

Awesome, thanks! Just need @mattr-'s 👍 then we'll be good. :)

@parkr parkr added this to the 2.0 milestone Apr 1, 2014

@parkr

This comment has been minimized.

Copy link
Member

parkr commented Apr 2, 2014

@benhanzl Did you try this with your gem-installed jekyll 2.0.0.alpha.2? The tests here will always include rouge so there's no telling whether this helps.

@benhanzl

This comment has been minimized.

Copy link
Contributor Author

benhanzl commented Apr 3, 2014

@parkr I did. Initially I had just the gem 2.0.0.alpha.2 installed. To test this, I uninstalled rouge from my gemset and created a new site without getting the error.

@mattr-

This comment has been minimized.

Copy link
Member

mattr- commented Apr 3, 2014

it seems like this would conflict with #2189. Either one we pick I'm 👍 on.

parkr added a commit that referenced this pull request Apr 3, 2014

@parkr parkr merged commit f3c54fc into jekyll:master Apr 3, 2014

1 check passed

default The Travis CI build passed
Details
@benhanzl

This comment has been minimized.

Copy link
Contributor Author

benhanzl commented Apr 3, 2014

@parkr The reason this happens is because when the redcarpet_parser.rb is required the all require statements in the modules are executed. By moving the require 'rouge' into a "logic" statement, the require is executed at "runtime".

I can reproduce this in irb in a gemset without the rouge gem:

$ irb
2.1.1 :001 > module WithRouge
2.1.1 :002?>   require 'rouge'
2.1.1 :003?>   end
LoadError: cannot load such file -- rouge

But if the require is nested in a method:

$ irb
2.1.1 :001 > def a_method
2.1.1 :002?>   require 'rouge'
2.1.1 :003?>   end
 => :a_method
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.