SyntaxError: Unexpected token '(' when trying to run pdf2json - pdf2json

When I try to run pdf2json (without any parameters at all) I'm getting this error:
/usr/lib/node_modules/pdf2json/lib/p2jcmd.js:63
#continue(callback, err) {
^
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/pdf2json/bin/pdf2json:3:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
Here's the Dockerfile I tried to run it in:
FROM debian:bullseye
RUN apt-get update \
&& apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y nodejs \
&& npm install pdf2json -g
Any ideas?

Quoting https://github.com/modesty/pdf2json/issues/250:
The problem here is that these were breaking changes but only marked as a new (non-breaking) feature with a minor version increment. So calling npm audit fix actually forces this upgrade and breaks everything. This needs to be re-released as a MAJOR version increment to v2.0 and/or a bug patch released on the 1.x line to make this backwards compatible again.
The solution is to do npm install --save-exact pdf2json#1.2.5.

Related

systemctl not found while building mongo image

I am trying to build a mongo 4.4 image based on the official image Dockerfile but I am running into an issue with systemctl not found. The image itself has a line to remove it after setup, but not sure where it came from. Any ideas?
Setting up mongodb-org-database-tools-extra (4.4.0) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Setting up libkrb5support0:amd64 (1.16-2ubuntu0.1) ...
Setting up krb5-locales (1.16-2ubuntu0.1) ...
Setting up libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ...
Setting up libk5crypto3:amd64 (1.16-2ubuntu0.1) ...
Setting up libkrb5-3:amd64 (1.16-2ubuntu0.1) ...
Setting up libgssapi-krb5-2:amd64 (1.16-2ubuntu0.1) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Setting up mongodb-database-tools (100.1.1) ...
Setting up mongodb-org-mongos (4.4.0) ...
Setting up mongodb-org-tools (4.4.0) ...
Setting up mongodb-org-server (4.4.0) ...
/var/lib/dpkg/info/mongodb-org-server.postinst: 43: /var/lib/dpkg/info/mongodb-org-server.postinst: systemctl: not found
dpkg: error processing package mongodb-org-server (--configure):
installed mongodb-org-server package post-installation script subprocess returned error exit status 127
Setting up mongodb-org-shell (4.4.0) ...
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.
dpkg: error processing package mongodb-org (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Errors were encountered while processing:
mongodb-org-server
mongodb-org
[91mE: Sub-process /usr/bin/dpkg returned an error code (1)
[0mThe command '/bin/sh -c set -x && export DEBIAN_FRONTEND=noninteractive && apt-get update && echo "mongodb-org hold" | dpkg --set-selections && echo "mongodb-org-server hold" | dpkg --set-selections && echo "mongodb-org-shell hold" | dpkg --set-selections && echo "mongodb-org-mongos hold" | dpkg --set-selections && echo "mongodb-org-tools hold" | dpkg --set-selections && apt-get install -y ${MONGO_PACKAGE}=$MONGO_VERSION ${MONGO_PACKAGE}-server=$MONGO_VERSION ${MONGO_PACKAGE}-shell=$MONGO_VERSION ${MONGO_PACKAGE}-mongos=$MONGO_VERSION ${MONGO_PACKAGE}-tools=$MONGO_VERSION && rm -f /usr/local/bin/systemctl && rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/mongodb && mv /etc/mongod.conf /etc/mongod.conf.orig' returned a non-zero code: 100
To be precise
RUN ln -s /bin/echo /bin/systemctl
RUN apt-get -qqy install mongodb-org
FL3SH answer works but to convey the meaning more effectively you can create a symbolic link from /bin/systemctl to /bin/true.
/bin/true is a command wich always return 0 (the truthy value of the shell) so it does not fail. It's a standard way to indicate that you want to return true. See this SO post also
The command you need to add in the Dockerfile is:
RUN ln -s /bin/true /usr/local/bin/systemctl
or
RUN ln -s /bin/true /bin/systemctl
The effect is that you trick the post-install script by calling /bin/true instead of /bin/systemctl
You can find the same trick into the official mongodb Dockerfile 4.4 line 91 that haytham linked in his description.
/bin/echo works as well as /bin/true because echo returns 0 as well. You can try it by doing
echo "test"
echo $?
And you'll see 0 as the result of the second echo.
echo ln to /bin/systemctl solves the issue.

Cannot use %install in Swift Colab

I try to install a new library in Swift on Google Colab
%install '.package(url: "https://github.com/IBM-Swift/BlueCryptor.git", from: "1.0.28")' Cryptor
Then, there is an error
...
error: toolchain is invalid: could not find the `swiftc` at expected path /swift/toolchain/usr/bin/swiftc
Install Error: swift-build returned nonzero exit code 1.
But I check that swiftc does exist in /swift/toolchain/usr/bin.
Here's a Colab notebook
that demonstrate the error.
Please help.
Now I update it to the latest Swift version. By running this notebook:
https://colab.research.google.com/github/tensorflow/swift/blob/master/notebooks/install_latest_swift.ipynb
There's no error anymore. So, just need to update it.
You can also do it all from the Swift notebook as well, using this code.
import Python
Python.import("subprocess").getoutput("""
rm -rf /swift
mkdir -p /swift/toolchain
wget -nv -O- https://storage.googleapis.com/s4tf-kokoro-artifact-testing/latest/swift-tensorflow-DEVELOPMENT-cuda10.0-cudnn7-ubuntu18.04.tar.gz | tar xzf - -C /swift/toolchain
wget -nv -O- https://storage.googleapis.com/s4tf-kokoro-artifact-testing/latest/swift-jupyter.tar.gz | tar xzf - -C /swift
python3 /swift/swift-jupyter/register.py --swift-toolchain /swift/toolchain
apt-get install libblocksruntime-dev
""")

MongoDB issue with mongoose

This is the message i am getting when i tries to run my new app any one who can fix this issue
^
Error: Cannot find module 'mongodb/node_modules/bson'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (C:\wamp\www\NodeExpress\beautiBlog\node_mo
ss-sessions\node_modules\mongoose\lib\drivers\node-mongodb-native\obj
16)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
[nodemon] app crashed - waiting for file changes before starting...
Try this:
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
Source: https://github.com/Automattic/mongoose/issues/2718

Install Perl Image::Magick on Fedora

I'm installing Image::Magick via cpan and I keep getting this error. I've tried with and without forcing it. I've trimmed the install log. I've read something about missing an ImageMagick.h file but don't exactly know anything other then that. Apparently this has been a common problem since 2007.....
[gandalf#Durmstrang ~]$ cpan -if Image::Magick
"/usr/bin/perl" "/usr/share/perl5/vendor_perl/ExtUtils/xsubpp" -typemap "/usr/share/perl5/ExtUtils/typemap" -typemap "typemap" Magick.xs > Magick.xsc && mv Magick.xsc Magick.c
gcc -c -I/usr/local/include/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"/usr/include/ImageMagick-6" -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/freetype2 -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DVERSION=\"6.89\" -DXS_VERSION=\"6.89\" -fPIC "-I/usr/lib64/perl5/CORE" -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
Magick.xs: In function ‘XS_Image__Magick_ComplexImages’:
Magick.xs:3475:5: error: unknown type name ‘ComplexOperator’
ComplexOperator
^
Magick.xs:3510:8: error: ‘UndefinedComplexOperator’ undeclared (first use in this function)
op=UndefinedComplexOperator;
^
Magick.xs:3510:8: note: each undeclared identifier is reported only once for each function it appears in
Magick.xs:3516:31: error: ‘MagickComplexOptions’ undeclared (first use in this function)
in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
^
Magick.xs:3524:13: error: ‘ComplexOperator’ undeclared (first use in this function)
op=(ComplexOperator) in;
^
Magick.xs:3524:30: error: expected ‘;’ before ‘in’
op=(ComplexOperator) in;
^
Magick.xs:3548:38: error: expected ‘;’ before ‘in’
op=(ComplexOperator) in;
^
Magick.xs:3563:5: warning: implicit declaration of function ‘ComplexImages’ [-Wimplicit-function-declaration]
image=ComplexImages(image,op,exception);
^
Magick.xs:3563:10: warning: assignment makes pointer from integer without a cast [enabled by default]
image=ComplexImages(image,op,exception);
^
Magick.xs: In function ‘XS_Image__Magick_Mogrify’:
Magick.xs:9824:11: warning: implicit declaration of function ‘RotationalBlurImageChannel’ [-Wimplicit-function-declaration]
image=RotationalBlurImageChannel(image,channel,geometry_info.rho,
^
Magick.xs:9824:16: warning: assignment makes pointer from integer without a cast [enabled by default]
image=RotationalBlurImageChannel(image,channel,geometry_info.rho,
^
Magick.xs:10895:11: warning: implicit declaration of function ‘CannyEdgeImage’ [-Wimplicit-function-declaration]
image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
^
Magick.xs:10895:16: warning: assignment makes pointer from integer without a cast [enabled by default]
image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
^
Magick.xs:10916:11: warning: implicit declaration of function ‘HoughLineImage’ [-Wimplicit-function-declaration]
image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
^
Magick.xs:10916:16: warning: assignment makes pointer from integer without a cast [enabled by default]
image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
^
Magick.xs:10939:11: warning: implicit declaration of function ‘MeanShiftImage’ [-Wimplicit-function-declaration]
image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
^
Magick.xs:10939:16: warning: assignment makes pointer from integer without a cast [enabled by default]
image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
^
make: *** [Magick.o] Error 1
JCRISTY/PerlMagick-6.89-1.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
The problem is that CPAN doesn't know about non-Perl dependencies.
The Perl Image::Magick module is just a wrapper around a C library. You'll need that library installed before you can build the Perl module.
$ sudo yum install ImageMagick
It also probably need ImageMagick's development package.
$ sudo yum install ImageMagick-devel
But it's probably easier to just install the RPM version that has already been packaged for Fedora (that will automatically pull in any other requirements).
$ sudo yum install ImageMagick-perl
In Fedora, CentOS, Ubuntu and more there have been this type of challenge in geting Image::Magick to install via the cpan program, and there have been sensitivities about the install-script for Image::Magick for a couple of years, it seems (if one searches around). This is so both for on desktop Linux and, even more so, via Apache cpanel. There are recipies but at least at Ubuntu, they have not been solving all issues. Sometimes, to get it right, one must first do removal of relevant libraries using ImageMagick to reset the links. All the proposed solutions center around installing other things before using 'cpan'. However, the best approach, I find, isn't at all to compile from source but to install the binary ImageMagick application when that is available, and relevant libraries before and after cpan, like this--in Ubuntu, but adapted for Fedora it should be similar or much the same:
sudo apt-get install perlmagick
sudo apt-get install ImageMagick
sudo cpan install Image::Magick
sudo apt-get install libperl-dev
For the sake of completeness, if one cannot find the right binary, one must take care to preinstall all relevant libraries as indicated on http://www.imagemagick.org and then this set of commands will replace the line#2 above, when performed after 'sudo -i' (in Ubuntu) or equivalent in Fedora, inside a temporary folder:
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd Imag*
./configure --with-perl
make
make install
When this installation is complete, proceed with line#3 above. Adapt the beginning of the command to the form that fits with other forms of linuxes. After this, a perl program having use Image::Magick; in its start should be able to do such as resizing of jpg images etc flawlessly.

Building Emacs from git master complains errors in configure.ac

When I try to build Emacs from https://github.com/emacs-mirror/emacs at 4f54f7b using ./autogen.sh it errors as
Checking whether you have the necessary tools...
(Read INSTALL.REPO for more details on building Emacs)
Checking for autoconf (need at least version 2.65)...
ok
Checking for automake (need at least version 1.11)...
ok
Your system has the required tools.
Running 'autoreconf -fi -I m4' ...
configure.ac:54: error: possibly undefined macro: AS_ECHO
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:95: error: possibly undefined macro: AM_INIT_AUTOMAKE
configure.ac:245: error: possibly undefined macro: AC_DEFINE
configure.ac:752: error: possibly undefined macro: AM_PROG_CC_C_O
configure.ac:763: error: possibly undefined macro: AM_CONDITIONAL
configure.ac:1020: error: possibly undefined macro: AM_SUBST_NOTMAKE
configure.ac:1471: error: possibly undefined macro: m4_default
autoreconf: /usr/bin/autoconf failed with exit status: 1
I've tried the common tricks to solve it without success. What to do?
Update: make bootstrap fails as
cd . && ACLOCAL_PATH='' /bin/bash /home/per/Work/emacs/build-aux/missing aclocal-1.14 -I m4
if [ -x ./config.status ]; then \
./config.status --recheck; \
else \
./configure --cache-file=/dev/null; \
fi
cd . && /bin/bash /home/per/Work/emacs/build-aux/missing automake-1.14 --gnu -a -c lib/Makefile
[ -r "src/config.in" ] || ( cd . && /bin/bash /home/per/Work/emacs/build-aux/missing autoheader )
running CONFIG_SHELL=/bin/bash /bin/bash ./configure --prefix=/home/per/opt/x86_64-unknown-linux-gnu/emacs-snapshot CFLAGS=-O2 PKG_CONFIG_PATH=/home/per/opt/x86_64-unknown-linux-gnu/fish-snapshot/share/pkgconfig:/home/per/opt/x86_64-unknown-linux-gnu/sparsehash-2.0.2/lib/pkgconfig:/home/per/opt/x86_64-unknown-linux-gnu/igraph-0.6/lib/pkgconfig:/home/per/opt/x86_64-unknown-linux-gnu/libarchive-snapshot/lib/pkgconfig:/home/per/opt/x86_64-unknown-linux-gnu/libgit2-snapshot/lib/pkgconfig:/home/per/opt/x86_64-unknown-linux-gnu/nettle-3.0/lib/pkgconfig: --no-create --no-recursion
checking for xcrun... no
checking for GNU Make... make
./configure: line 2853: syntax error near unexpected token `1.11'
./configure: line 2853: `AM_INIT_AUTOMAKE(1.11)'
Makefile:412: receptet för målet ”config.status” misslyckades
make: *** [config.status] Fel 2