linjer / jekyll-katex

[DEPRECATED] Jekyll plugin for easy server-side math rendering via KaTeX
MIT License
96 stars 8 forks source link

Javascript engine missing! #26

Open MahdiBaghbani opened 4 years ago

MahdiBaghbani commented 4 years ago

Hi, first of all thanks for this plugin and please add support for Jekyll 4.0 :)

and now the actual issue: I'm building Jekyll in a gitlab ci-cd for 1 project that has two branches: master and development they have same katex config but in master I get this error

 $ bundle info jekyll-katex
  * jekyll-katex (0.4.3)
    Summary: Jekyll plugin for easy KaTeX math server-side rendering.
    Homepage: https://github.com/linjer/jekyll-katex
    Path: /usr/local/rvm/gems/ruby-2.6.3/gems/jekyll-katex-0.4.3
$ bundle exec jekyll build -d public
Configuration file: /builds/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/_config.yml
Configuration file: /builds/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/_config.yml
jekyll 3.8.6 | Error:  Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.

while on development branch everything runs just fine:

$ bundle info jekyll-katex
  * jekyll-katex (0.4.3)
    Summary: Jekyll plugin for easy KaTeX math server-side rendering.
    Homepage: https://github.com/linjer/jekyll-katex
    Path: /usr/local/rvm/gems/ruby-2.6.3/gems/jekyll-katex-0.4.3

$ bundle exec jekyll build -d development
Configuration file: /builds/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/_config.yml
Configuration file: /builds/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/_config.yml
Katex Configuration: Found KaTeX js at: /usr/local/rvm/gems/ruby-2.6.3/gems/jekyll-katex-0.4.3/lib/assets/js/katex.min.js
            Source: /builds/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme
       Destination: development
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    done in 5.36 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

can you look at this? i'm really confused and used many ways to solve it but still failed.

thank you

MahdiBaghbani commented 4 years ago

Update:

When I set

js_path: "{{ Gem::lib_path }}/assets/js"

in master and development , build failed for both!

links to full build log: master - https://gitlab.com/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/-/jobs/284987975 development - https://gitlab.com/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/-/jobs/284987489

interesting that error message is different.

I removed js_path from both branches _config.yml.

master - https://gitlab.com/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/-/jobs/284988532 development - https://gitlab.com/Azadeh-Afzar/Web-Development/Kianic-Jekyll-Theme/-/jobs/284989285

master failed and development succeed!

I don't know whats wrong here ...

MahdiBaghbani commented 4 years ago

now I feel I'm stupid!

I just downloaded katex.min.js from your repo, and placed it inside my Jekyll theme repo and set js-path to point to it, everything is working in my local machine and yet again in gitlab ci development branch build succeed and master failed! EVEN THAT I HAD A KATEX JS INCLUDED.

So I've started to read you actual source code to find out both js_filename and js_path, I understood that katex in _config.yml is optional because you have already hard coded them into source code and it will call a merge function to fetch user settings from _config.yml.

After reading error messages it's clear that problem isn't katex because it's not producing the ones you have set in source codes.

but why development succeed and master failed? I found it in a hard way (my stupid self) apparently Jekyll is somehow dependent on node.js when using katex (how on earth is this possible? it's not in Jekyll docs, nowhere else) by just installing node.js before bundle install command, everything worked fine.

You may want to test this yourself and add it to katex documentation in future.

linjer commented 4 years ago

Thanks for a very detailed report!

To clarify, Jekyll is not dependent on node.js at all, but it's this jekyll-katex plugin that requires some kind of JS engine which can either be rhino, node, or some other. Since KaTeX is fully written in JS, it's hard to get around this.

The engine is selected by the execjs gem and the original error you got was due to a failure to find a JS execution engine.

I have it on my long list of TODOs to embed a javascript engine and stop using execjs (appears unmaintained) so users do not need to provide one and it allows for a more consistent/robust experience. I did not add the JS engine requirement to the docs because it's common for most systems to have an engine installed somewhere and I hope to remove this requirement.

I think the problems you ran into are indeed confusing and maybe I can find just a little time to clarify in docs/errors. I'll also try to figure out why it was working on master and not on a dev branch.

Other suggestions appreciated.

MahdiBaghbani commented 4 years ago

Hi, I already know why it was working on dev and failed on master. Dev branch has a ci job to push the site to surge.sh. So basically it has a command to install node.js which is necessary for surge before going to “bundle exec jekyll build”, thus everything was ok on dev branch

But in master, the job was just to build site for gitlab pages without any node.js installation. and that causes this painful confusion for me, I figured out it also needs node.js too :)

On Tue, Sep 3, 2019 at 11:15 PM Jerry Lin notifications@github.com wrote:

Thanks for a very detailed report!

To clarify, Jekyll is not dependent on node.js at all, but it's this jekyll-katex plugin that requires some kind of JS engine which can either be rhino, node, or some other. Since KaTeX is fully written in JS, it's hard to get around this.

The engine is selected by the execjs gem and the original error you got was due to a failure to find a JS execution engine.

I have it on my long list of TODOs to embed a javascript engine and stop using execjs (appears unmaintained) so users do not need to provide one and it allows for a more consistent/robust experience. I did not add the JS engine requirement to the docs because it's common for most systems to have an engine installed somewhere and I hope to remove this requirement.

I think the problems you ran into are indeed confusing and maybe I can find just a little time to clarify in docs/errors. I'll also try to figure out why it was working on master and not on a dev branch.

Other suggestions appreciated.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/linjer/jekyll-katex/issues/26?email_source=notifications&email_token=ADIMIGB4WRWVJAQZRQCXAKDQH2WD3A5CNFSM4ISWRIV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ZFUFY#issuecomment-527587863, or mute the thread https://github.com/notifications/unsubscribe-auth/ADIMIGGQJJJRNY4GYCUX2PDQH2WD3ANCNFSM4ISWRIVQ .

-- https://about.me/mahdibaghbani?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb Mahdi Baghbani about.me/mahdibaghbani https://about.me/mahdibaghbani?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb