access-company / kotlin_intro

introduction of Kotlin!
9 stars 5 forks source link

gitbook installが失敗する #42

Closed ghost closed 2 years ago

ghost commented 2 years ago

概要

gitbook installが失敗する

nagauchi@Y61-41523 kotlin_intro % gitbook install           
Installing GitBook 3.2.3
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
/Users/nagauchi/.asdf/installs/nodejs/14.17.1/.npm/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287
      if (cb) cb.apply(this, arguments)
                 ^
TypeError: cb.apply is not a function
    at /Users/nagauchi/.asdf/installs/nodejs/14.17.1/.npm/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:193:5)

分析

以上やっても解決せず、一度調査を打ち切った。

直接的な原因じゃないかもしれないが、調査していて感じた問題が2つあり、

  1. 今年の講師(@tonionagauzzi)が業務ではWeb開発をしており、npmのバージョンを複数入れたり何なりでローカルがとっ散らかる
  2. 2022年現在、Gitbookは更新が止まり、ホスティングサービスへ移行している

以上から、1.はDocker、2.はHonkit移行で対応し、そのあと同種の問題が起きなければOK。

ghost commented 2 years ago

Honkitのbuildが失敗する。

root@3162892497ce:/workspaces/kotlin_intro# cd src
root@3162892497ce:/workspaces/kotlin_intro/src# honkit build         
(node:10515) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)
ReferenceError: Failed to load HonKit's plugin module: "uml" is not found.

cwd: /workspaces/kotlin_intro/src
baseDir: 

    at PluginResolver.resolvePluginPackageName (/usr/local/lib/node_modules/honkit/lib/plugins/PluginResolver.js:74:19)
    at /usr/local/lib/node_modules/honkit/lib/plugins/loadForBook.js:26:34
    at /usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:3016:46
    at List.__iterate (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:2206:13)
    at IndexedIterable.mappedSequence.__iterateUncached (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:3015:23)
    at seqIterate (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:604:16)
    at IndexedIterable.IndexedSeq.__iterate (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:320:14)
    at IndexedIterable.toArray (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:4258:23)
    at List [as constructor] (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:2065:62)
    at reify (/usr/local/lib/node_modules/honkit/node_modules/immutable/dist/immutable.js:3570:37)

エラーによるとumlが無いとのことで入れると、それも失敗する

root@3162892497ce:/workspaces/kotlin_intro/src# npm install -g gitbook-plugin-uml
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/gitbook-plugin-uml/node_modules/node-plantuml-back
npm ERR! command failed
npm ERR! command sh -c npm run getpuml && node scripts/get-vizjs.js
npm ERR! > node-plantuml-back@1.1.0 getpuml
npm ERR! > node scripts/get-plantuml-jar.js
npm ERR! 
npm ERR! plantuml.jar version 1.2021.9 already exist, if you want update please delete it.
npm ERR! node:events:498
npm ERR!       throw er; // Unhandled 'error' event
npm ERR!       ^
npm ERR! 
npm ERR! Error: spawn java ENOENT
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
npm ERR!     at onErrorNT (node:internal/child_process:478:16)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! Emitted 'error' event on ChildProcess instance at:
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
npm ERR!     at onErrorNT (node:internal/child_process:478:16)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
npm ERR!   errno: -2,
npm ERR!   code: 'ENOENT',
npm ERR!   syscall: 'spawn java',
npm ERR!   path: 'java',
npm ERR!   spawnargs: [
npm ERR!     '-Dplantuml.include.path=/usr/local/lib/node_modules/gitbook-plugin-uml/node_modules/node-plantuml-back',
npm ERR!     '-Djava.awt.headless=true',
npm ERR!     '-jar',
npm ERR!     '/usr/local/lib/node_modules/gitbook-plugin-uml/node_modules/node-plantuml-back/vendor/plantuml.jar',
npm ERR!     '-testdot'
npm ERR!   ]
npm ERR! }

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-03-07T09_22_26_838Z-debug-0.log

umlが無いってのはプラグインの指定の話?でもここ

gitbook installコマンドを使っている場合は単純に削除して、 代わりにgitbook-plugin-*の各プラグインパッケージを明示的にnpmでインストールしてください。

とあって、有力なdocっぽいので、それには従っている。

で、やっぱりgitbookを使おうと思うと、Docker内だろうがissue冒頭のエラーが出るし、昨今は脆弱性の懸念とかもあるから古いバージョンで組み直したりは極力したくない。

今のところhonkitでビルドできるようにするのが目下のゴール。

本日はわからないので調査継続予定。

ghost commented 2 years ago

上記はプラグイン不足 https://github.com/access-company/kotlin_intro/commit/0ac884c14f3fc40500696f370729d344cc329594 が原因だったが、また違うビルドエラーに直面

root@d8590bb8e9b8:/workspaces/kotlin_intro# make
(略)
rendering error: Template render error: (/usr/local/lib/node_modules/honkit/node_modules/gitbook-plugin-search/_layouts/website/page.html)
  RangeError: Maximum call stack size exceeded
    at Object._prettifyError (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/lib.js:36:11)
    at /usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:563:19
    at Template.root [as rootRenderFunc] (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:48:3)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:42:16)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:29:46)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:29:93)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:25:46)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:25:91)
    at createTemplate (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:315:9)
    at handle (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:327:11)
error: error while generating page "overview.md": 
error: error while generating page "about_kotlin.md": 
error: error while generating page "generics.md": 
error: error while generating page "development_environment.md": 
error: error while generating page "function.md": 
error: error while generating page "interface.md": 
error: error while generating page "exercise3.md": 
error: error while generating page "exercise1.md": 
error: error while generating page "first_class_function.md": 
error: error while generating page "exercise2.md": 
error: error while generating page "class.md": 
error: error while generating page "inherit_abstract.md": 
error: error while generating page "null_safe.md": 
error: error while generating page "tips.md": 
error: error while generating page "basic_syntax.md": 
Template render error: (/usr/local/lib/node_modules/honkit/node_modules/gitbook-plugin-search/_layouts/website/page.html)
  RangeError: Maximum call stack size exceeded
    at Object._prettifyError (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/lib.js:36:11)
    at /usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:563:19
    at Template.root [as rootRenderFunc] (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:48:3)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:42:16)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:29:46)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:29:93)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:25:46)
    at eval (eval at _compile (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:25:91)
    at createTemplate (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:315:9)
    at handle (/usr/local/lib/node_modules/honkit/node_modules/nunjucks/src/environment.js:327:11)
make: *** [Makefile:7: /workspaces/kotlin_intro/src/node_modules] Error 1
root@d8590bb8e9b8:/workspaces/kotlin_intro# 

ググってlunrを除外したり--reloadつけたりしたが効果なし。

ghost commented 2 years ago

gitbook-plugin-search-pro-kuiを使うと上記起きなくなった。 日本語対応もできて一石二鳥!

44 のマージでissueクローズ予定。