phiresky / pandoc-url2cite

Effortlessly and transparently add correctly styled citations to your markdown paper given only a URL
Other
122 stars 9 forks source link

Unable to run in pandoc Docker container #9

Closed ghost closed 3 years ago

ghost commented 3 years ago

Sorry, me again! I saw that #8 may be resolved in the new version of pandoc, so I decided to try and test it by running pandoc-url2cite in the latest pandoc Docker container.

I couldn't get pandoc-url2cite to run in one of the official pandoc Docker containers (Alpine Linux-based).

Steps to Reproduce

Create Dockerfile and script.sh file as per the pandoc Dockerfile README

I extended the Dockerfile to install pandoc-url2cite:

FROM pandoc/latex:latest

RUN apk --update add npm \
  && npm install --verbose -g pandoc-url2cite

script.sh:

#!/bin/sh
pandoc --filter=pandoc-url2cite --citeproc --csl ieee-with-url.csl minimal.md -o out.pdf

Build the docker container (I set npm to verbose, output in full output)

Run the docker container; it produces an error apparently relating to pandoc-url2cite:

_$ docker run --rm --volume "`pwd`:/data" --entrypoint "/data/script.sh" testpandoc:latest
/usr/lib/node_modules/pandoc-url2cite/dist/index.js:112
        const escapeIds = meta["url2cite-escape-ids"] ?? true;
                                                       ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:4:17)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
Error running filter pandoc-url2cite:
Filter returned error status 1

Full Output

_$ ls
Dockerfile  ieee-with-url.csl  minimal.md  script.sh
_$ cat Dockerfile
FROM pandoc/latex:latest

RUN apk --update add npm \
  && npm install --verbose -g pandoc-url2cite
_$ cat script.sh
#!/bin/sh
pandoc --filter=pandoc-url2cite --citeproc --csl ieee-with-url.csl minimal.md -o out.pdf
_$ docker build -t localhost/testpandoc .
STEP 1: FROM pandoc/latex:latest
STEP 2: RUN apk --update add npm   && npm install --verbose -g pandoc-url2cite
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/6) Installing ca-certificates (20191127-r4)
(2/6) Installing c-ares (1.16.1-r0)
(3/6) Installing nghttp2-libs (1.41.0-r0)
(4/6) Installing libstdc++ (9.3.0-r2)
(5/6) Installing nodejs (12.22.1-r0)
(6/6) Installing npm (12.22.1-r0)
Executing busybox-1.31.1-r20.trigger
Executing ca-certificates-20191127-r4.trigger
OK: 149 MiB in 89 packages
npm info it worked if it ends with ok
npm verb cli [
npm verb cli   '/usr/bin/node',
npm verb cli   '/usr/bin/npm',
npm verb cli   'install',
npm verb cli   '--verbose',
npm verb cli   '-g',
npm verb cli   'pandoc-url2cite'
npm verb cli ]
npm info using npm@6.14.12
npm info using node@v12.22.1
npm verb npm-session ad793db4ad000209
npm http fetch GET 200 https://registry.npmjs.org/pandoc-url2cite 127ms
npm http fetch GET 200 https://registry.npmjs.org/pandoc-url2cite/-/pandoc-url2cite-0.6.7.tgz 75ms
npm timing stage:loadCurrentTree Completed in 268ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms
npm http fetch GET 200 https://registry.npmjs.org/node-fetch 41ms
npm http fetch GET 200 https://registry.npmjs.org/pandoc-filter 61ms
npm http fetch GET 200 https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz 38ms
npm http fetch GET 200 https://registry.npmjs.org/pandoc-filter/-/pandoc-filter-2.0.2.tgz 45ms
npm http fetch GET 200 https://registry.npmjs.org/get-stdin 30ms
npm http fetch GET 200 https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz 32ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 207ms
npm timing stage:loadIdealTree Completed in 214ms
npm timing stage:generateActionsToTake Completed in 7ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
npm timing action:extract Completed in 46ms
npm timing action:finalize Completed in 14ms
npm timing action:refresh-package-json Completed in 43ms
npm info lifecycle get-stdin@7.0.0~preinstall: get-stdin@7.0.0
npm info lifecycle node-fetch@2.6.1~preinstall: node-fetch@2.6.1
npm info lifecycle pandoc-filter@2.0.2~preinstall: pandoc-filter@2.0.2
npm info lifecycle pandoc-url2cite@0.6.7~preinstall: pandoc-url2cite@0.6.7
npm timing action:preinstall Completed in 2ms
npm info linkStuff get-stdin@7.0.0
npm info linkStuff node-fetch@2.6.1
npm info linkStuff pandoc-filter@2.0.2
npm info linkStuff pandoc-url2cite@0.6.7
npm verb linkBins [ { 'pandoc-url2cite': 'dist/pandoc-url2cite.js' }, '/usr/bin', true ]
/usr/bin/pandoc-url2cite -> /usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js
npm timing action:build Completed in 8ms
npm info lifecycle get-stdin@7.0.0~install: get-stdin@7.0.0
npm info lifecycle node-fetch@2.6.1~install: node-fetch@2.6.1
npm info lifecycle pandoc-filter@2.0.2~install: pandoc-filter@2.0.2
npm info lifecycle pandoc-url2cite@0.6.7~install: pandoc-url2cite@0.6.7
npm timing action:install Completed in 1ms
npm info lifecycle get-stdin@7.0.0~postinstall: get-stdin@7.0.0
npm info lifecycle node-fetch@2.6.1~postinstall: node-fetch@2.6.1
npm info lifecycle pandoc-filter@2.0.2~postinstall: pandoc-filter@2.0.2
npm info lifecycle pandoc-url2cite@0.6.7~postinstall: pandoc-url2cite@0.6.7
npm timing action:postinstall Completed in 1ms
npm verb unlock done using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
npm timing stage:executeActions Completed in 130ms
npm timing stage:rollbackFailedOptional Completed in 0ms
npm timing stage:runTopLevelLifecycles Completed in 620ms
+ pandoc-url2cite@0.6.7
added 4 packages from 3 contributors in 0.623s
npm verb exit [ 0, true ]
npm timing npm Completed in 1077ms
npm info ok
STEP 3: COMMIT localhost/testpandoc
--> fcd9cc2f329
Successfully tagged localhost/testpandoc:latest
fcd9cc2f3292fd589772b3f1c7354f98f4f73265bcce3b78a9a4eeb758e86634
_$ docker run --rm --volume "`pwd`:/data" --entrypoint "/data/script.sh" testpandoc:latest
/usr/lib/node_modules/pandoc-url2cite/dist/index.js:112
        const escapeIds = meta["url2cite-escape-ids"] ?? true;
                                                       ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:4:17)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
Error running filter pandoc-url2cite:
Filter returned error status 1
_$ docker run --entrypoint "/usr/bin/env" -it --rm testpandoc /bin/ash
/data # pandoc-url2cite --version
/usr/lib/node_modules/pandoc-url2cite/dist/index.js:112
        const escapeIds = meta["url2cite-escape-ids"] ?? true;
                                                       ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:4:17)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
/data # pandoc --version
pandoc 2.14.0.2
Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.10.5.1,
citeproc 0.4.0.1, ipynb 0.1.0.1
User data directory: /root/.local/share/pandoc
Copyright (C) 2006-2021 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
/data # npm --version
6.14.12
/data # node --version
v12.22.1
/data # cat /etc/alpine-release
3.12.7
phiresky commented 3 years ago

That syntax error is caused by a too old node version

On Sat, Jun 19, 2021, 04:54 Rob @.***> wrote:

Sorry, me again! I saw that #8 https://github.com/phiresky/pandoc-url2cite/issues/8 may be resolved in the new version of pandoc, so I decided to try and test it by running pandoc-url2cite in the latest pandoc Docker container.

I couldn't get pandoc-url2cite to run in one of the official pandoc Docker containers (Alpine Linux-based). Steps to Reproduce

Create Dockerfile and script.sh file as per the pandoc Dockerfile README https://github.com/pandoc/dockerfiles

I extended the Dockerfile to install pandoc-url2cite:

FROM pandoc/latex:latest

RUN apk --update add npm \ && npm install --verbose -g pandoc-url2cite

script.sh:

!/bin/sh

pandoc --filter=pandoc-url2cite --citeproc --csl ieee-with-url.csl minimal.md -o out.pdf

Build the docker container (I set npm to verbose, output in full output)

Run the docker container; it produces an error apparently relating to pandoc-url2cite:

_$ docker run --rm --volume "pwd:/data" --entrypoint "/data/script.sh" testpandoc:latest /usr/lib/node_modules/pandoc-url2cite/dist/index.js:112 const escapeIds = meta["url2cite-escape-ids"] ?? true; ^

SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:4:17) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) Error running filter pandoc-url2cite: Filter returned error status 1

Full Output

$ ls Dockerfile ieee-with-url.csl minimal.md script.sh $ cat Dockerfile FROM pandoc/latex:latest

RUN apk --update add npm \ && npm install --verbose -g pandoc-url2cite _$ cat script.sh

!/bin/sh

pandoc --filter=pandoc-url2cite --citeproc --csl ieee-with-url.csl minimal.md -o out.pdf _$ docker build -t localhost/testpandoc . STEP 1: FROM pandoc/latex:latest STEP 2: RUN apk --update add npm && npm install --verbose -g pandoc-url2cite fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz (1/6 http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz(1/6) Installing ca-certificates (20191127-r4) (2/6) Installing c-ares (1.16.1-r0) (3/6) Installing nghttp2-libs (1.41.0-r0) (4/6) Installing libstdc++ (9.3.0-r2) (5/6) Installing nodejs (12.22.1-r0) (6/6) Installing npm (12.22.1-r0) Executing busybox-1.31.1-r20.trigger Executing ca-certificates-20191127-r4.trigger OK: 149 MiB in 89 packages npm info it worked if it ends with ok npm verb cli [ npm verb cli '/usr/bin/node', npm verb cli '/usr/bin/npm', npm verb cli 'install', npm verb cli '--verbose', npm verb cli '-g', npm verb cli 'pandoc-url2cite' npm verb cli ] npm info using @. npm info using @. npm verb npm-session ad793db4ad000209 npm http fetch GET 200 https://registry.npmjs.org/pandoc-url2cite 127ms npm http fetch GET 200 https://registry.npmjs.org/pandoc-url2cite/-/pandoc-url2cite-0.6.7.tgz 75ms npm timing stage:loadCurrentTree Completed in 268ms npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms npm timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms npm http fetch GET 200 https://registry.npmjs.org/node-fetch 41ms npm http fetch GET 200 https://registry.npmjs.org/pandoc-filter 61ms npm http fetch GET 200 https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz 38ms npm http fetch GET 200 https://registry.npmjs.org/pandoc-filter/-/pandoc-filter-2.0.2.tgz 45ms npm http fetch GET 200 https://registry.npmjs.org/get-stdin 30ms npm http fetch GET 200 https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz 32ms npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 207ms npm timing stage:loadIdealTree Completed in 214ms npm timing stage:generateActionsToTake Completed in 7ms npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing npm verb lock using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging npm timing action:extract Completed in 46ms npm timing action:finalize Completed in 14ms npm timing action:refresh-package-json Completed in 43ms npm info lifecycle @.~preinstall: @. npm info lifecycle @.~preinstall: @. npm info lifecycle @.~preinstall: @. npm info lifecycle @.~preinstall: @. npm timing action:preinstall Completed in 2ms npm info linkStuff @. npm info linkStuff @. npm info linkStuff @. npm info linkStuff @. npm verb linkBins [ { 'pandoc-url2cite': 'dist/pandoc-url2cite.js' }, '/usr/bin', true ] /usr/bin/pandoc-url2cite -> /usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js npm timing action:build Completed in 8ms npm info lifecycle @.~install: @. npm info lifecycle @.~install: @. npm info lifecycle @.~install: @. npm info lifecycle @.~install: @. npm timing action:install Completed in 1ms npm info lifecycle @.~postinstall: @. npm info lifecycle @.~postinstall: @. npm info lifecycle @.~postinstall: @. npm info lifecycle @.~postinstall: @. npm timing action:postinstall Completed in 1ms npm verb unlock done using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging npm timing stage:executeActions Completed in 130ms npm timing stage:rollbackFailedOptional Completed in 0ms npm timing stage:runTopLevelLifecycles Completed in 620ms

  • @.*** added 4 packages from 3 contributors in 0.623s npm verb exit [ 0, true ] npm timing npm Completed in 1077ms npm info ok STEP 3: COMMIT localhost/testpandoc --> fcd9cc2f329 Successfully tagged localhost/testpandoc:latest fcd9cc2f3292fd589772b3f1c7354f98f4f73265bcce3b78a9a4eeb758e86634 _$ docker run --rm --volume "pwd:/data" --entrypoint "/data/script.sh" testpandoc:latest /usr/lib/node_modules/pandoc-url2cite/dist/index.js:112 const escapeIds = meta["url2cite-escape-ids"] ?? true; ^

SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:4:17) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module.extensions..js (internal/modules/cjs/loader.js:1027:10) Error running filter pandoc-url2cite: Filter returned error status 1 $ docker run --entrypoint "/usr/bin/env" -it --rm testpandoc /bin/ash /data # pandoc-url2cite --version /usr/lib/node_modules/pandoc-url2cite/dist/index.js:112 const escapeIds = meta["url2cite-escape-ids"] ?? true; ^

SyntaxError: Unexpected token '?' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object. (/usr/lib/node_modules/pandoc-url2cite/dist/pandoc-url2cite.js:4:17) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) /data # pandoc --version pandoc 2.14.0.2 Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.10.5.1, citeproc 0.4.0.1, ipynb 0.1.0.1 User data directory: /root/.local/share/pandoc Copyright (C) 2006-2021 John MacFarlane. Web: https://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose. /data # npm --version 6.14.12 /data # node --version v12.22.1 /data # cat /etc/alpine-release 3.12.7

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/phiresky/pandoc-url2cite/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARSOYOYFJZ2OEWKNHIXUVLTTQBGLANCNFSM466TYMGQ .

ghost commented 3 years ago

That's fixed it!

I ran it with this Dockerfile (i.e. installing nodejs-current):

FROM pandoc/latex:latest

RUN apk --update add nodejs-current npm \
  && npm install -g pandoc-url2cite

Would it be possible to inform users of this in some way, such as showing compatible node versions in the README file, or some change in the npm package settings?

phiresky commented 3 years ago

Great! I've added the requirement of node 14 to the package definition. It should now show

Unsupported engine for pandoc-url2cite@0.6.8: wanted: {"node":">=14"} (current: {"node":"12.22.1","npm":"6.14.12"})

if used on an older node version