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

Javascript engine missing! #26

Open
MahdiBaghbani opened this issue Sep 1, 2019 · 4 comments
Open

Javascript engine missing! #26

MahdiBaghbani opened this issue Sep 1, 2019 · 4 comments

Comments

@MahdiBaghbani
Copy link

MahdiBaghbani commented Sep 1, 2019

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
Copy link
Author

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
Copy link
Author

MahdiBaghbani commented Sep 1, 2019

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
Copy link
Owner

linjer commented Sep 3, 2019

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
Copy link
Author

MahdiBaghbani commented Sep 4, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants