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

Error: libcups.so.2: cannot open shared object file: No such file or directory #9

Closed
marisaroude opened this issue Jan 15, 2024 · 13 comments

Comments

@marisaroude
Copy link

Hi! I need help with this problem. I'm deploying in vercel but i have this error:

Error: libcups.so.2: cannot open shared object file: No such file or directory
at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at r..e._load (/var/task/___vc/__launcher/bridge-server-72TT5FOD.js:1:1574)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object. (/var/task/node_modules/@damonsmith/node-printer/lib/printer-binding.js:4:17)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'ERR_DLOPEN_FAILED'
}
INIT_REPORT Init Duration: 1022.90 ms Phase: invoke Status: error Error Type: Runtime.ExitError
Error: Runtime exited with error: exit status 1
Runtime.ExitError

@mazinsw
Copy link

mazinsw commented Jan 15, 2024

Hi, on linux based system it's required to install libcups2, try this command: sudo apt-get install libcups2-dev

@marisaroude
Copy link
Author

Hi! thank you for your reply.
Yes, I have the package installed. I do not understand what I am missing.
image

@marisaroude
Copy link
Author

Is it necessary to use electron? Because I am not implementing it

@mazinsw
Copy link

mazinsw commented Jan 15, 2024

It is tested on electron, but it should work on node too, this problem seems a missing system lib path, check if this path get from this command whereis libcups.so.2 is listed here by this command cat /etc/ld.so.conf.d/*

@marisaroude
Copy link
Author

I got this result, should I add the following line in one of the .conf files?

/usr/lib/x86_64-linux-gnu/libcups.so.2

image

@mazinsw
Copy link

mazinsw commented Jan 15, 2024

It already contains the path, can be a problem on node_modules installation folder, did you remove nodes_modules and reinstalled?
if not solve check if this command ldd node_modules/@grandchef/node-printer/lib/binding/node_printer.node | grep libcups output like this: libcups.so.2 => /usr/lib/x86_64-linux-gnu/libcups.so.2 (0x00007efde22b4000)
if different try creating a alias: sudo ln -s /usr/lib/x86_64-linux-gnu/libcups.so.2 /lib/x86_64-linux-gnu/libcups.so.2

directory /lib/x86_64-linux-gnu/ must exists, if not, make with: sudo mkdir -p /lib/x86_64-linux-gnu/

image

@marisaroude
Copy link
Author

I tried to remove node_modules and reinstall the dependencies, but it didn't work.

I understand that this command ldd node_modules/@grandchef/node-printer/lib/binding/node_printer.node | grep libcups returns fine.

What I find strange is that I get perfect execution and printing on the thermal printer when I play the GraphQL mutation that performs this action on localhost.

I think maybe I am having problems with the LD_LIBRARY_PATH environment variable, is it possible?

image

@marisaroude
Copy link
Author

Replace @grandchef with @damonsmith as that was the one I installed.

@mazinsw
Copy link

mazinsw commented Jan 16, 2024

Now its get more clear, the build was made at a different OS base than vercel are try to run, this explain why it is not finding the library, try to build at the same OS/Container than vercel

@marisaroude
Copy link
Author

Like Docker?
Before implementing printing with the thermal printer, I had already deployed it and it worked perfectly.
Sorry for so many questions, it's the first time I implement a thermal printer and deploy in vercel.

@marisaroude
Copy link
Author

I was able to perform different queries and other mutations, for example, add, update, get, and others.

@mazinsw
Copy link

mazinsw commented Jan 16, 2024

Yes, docker has many base container like, alpine, ubuntu, debian, you must build with the same base container than vercel https://vercel.com/docs/deployments/build-image

I undersant that when not loaded the library the error does not occurr, this explain why some queries does not trigger the error

@marisaroude
Copy link
Author

Perfect, I'll go that way.
Thank you very much!

@mazinsw mazinsw closed this as completed Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants