NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.96k stars 13.97k forks source link

Inkcut does not start CUPS print jobs #130351

Closed MatthewCroughan closed 3 years ago

MatthewCroughan commented 3 years ago

Describe the bug Inkcut is unable to print to a cups printer.

To Reproduce Steps to reproduce the behavior:

  1. Add services.printing.enable = true; to your config
  2. Navigate to 127.0.0.1:631 and add a printer that points to a local vinyl cutter or printer device via its USB device name, for example usb://Roland/GX-300?serial=0001
  3. Set the printer driver for this device to Raw > Raw Print Queue
  4. Open Inkcut, go to Setup and make a profile for your printer that points to this new printer
  5. Attempt to "Send to device" (Ctrl + P) in Inkcut
  6. Observe that nothing happens, no new print job is started

Expected behavior Inkcut would start a print job in cups

Notify maintainers @raboof

Metadata

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
raboof commented 3 years ago

Note that as a workaround you can likely use the USB-to-serial device directly as a serial interface without going through CUPS - I'm pretty sure that's the setup in https://github.com/bibliotheekdeventer/makersplaats/blob/master/images/configuration.nix / https://github.com/bibliotheekdeventer/makersplaats/blob/master/images/inkcut.device.json .

We should still fix it so it also works via CUPS, of course :)

MatthewCroughan commented 3 years ago

In my case, your workaround is not as nice as using cups, since Inkcut improperly handles the lp0 (parallel) and serial is not an option for my cutter. Cups handles the jobs properly, if the vinyl cutter is powered off half-way through a job it will not continue to send and buffer the job, it will halt the job and consider it done. So it's just a better method than to give Inkcut direct access to lp0.

raboof commented 3 years ago

I tried this, and under 'Setup' I do see my CUPS printers, so it looks like at least something works.

However, indeed when I send the job to the device, indeed I see nothing show up in the print queue. Looking at the inkcut logs, however, all looks fine:

2021-07-19 21:34:23,609 | INFO    | inkcut | device | Connecting to device
2021-07-19 21:34:23,609 | INFO    | inkcut | device | Processing job
2021-07-19 21:34:23,610 | DEBUG   | inkcut | device | connect
2021-07-19 21:34:23,622 | DEBUG   | inkcut | -> HP-LaserJet-4100 | IN;
2021-07-19 21:34:23,624 | DEBUG   | inkcut | HP-LaserJet-4100 | opened
2021-07-19 21:34:23,626 | INFO    | inkcut | device | Working...
2021-07-19 21:34:23,633 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PU1376,1412;
2021-07-19 21:34:23,637 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD852,1362;
2021-07-19 21:34:23,639 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD446,1698;
2021-07-19 21:34:23,640 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD396,2222;
2021-07-19 21:34:23,641 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD732,2628;
2021-07-19 21:34:23,643 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1256,2678;
2021-07-19 21:34:23,644 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1662,2343;
2021-07-19 21:34:23,645 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1712,1818;
2021-07-19 21:34:23,646 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1376,1412;
2021-07-19 21:34:23,647 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PU1217,120;
2021-07-19 21:34:23,649 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD577,113;
2021-07-19 21:34:23,649 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD120,560;
2021-07-19 21:34:23,651 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD113,1200;
2021-07-19 21:34:23,652 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD560,1657;
2021-07-19 21:34:23,653 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1200,1664;
2021-07-19 21:34:23,654 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1657,1217;
2021-07-19 21:34:23,655 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1664,577;
2021-07-19 21:34:23,655 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PD1217,120;
2021-07-19 21:34:23,657 | DEBUG   | inkcut | -> HP-LaserJet-4100 | PU0,0;
2021-07-19 21:34:23,657 | DEBUG   | inkcut | device | finish
2021-07-19 21:34:23,657 | DEBUG   | inkcut | -> HP-LaserJet-4100 | IN;
2021-07-19 21:34:23,657 | DEBUG   | inkcut | device | disconnect
2021-07-19 21:34:23,657 | DEBUG   | inkcut | HP-LaserJet-4100 | closed

Showing the 'completed jobs' in CUPS doesn't show this one, though - not as 'cancelled' either.

Adding some more diagnostic logging (https://github.com/inkcut/inkcut/pull/312) revealed that twisted is trying to run /usr/bin/lpr, which is of course not where that tool is located in NixOS. Making that an absolute path into the nix store seemed to help (at least things showed up in my CUPS queue, haven't tested with an actual plotter).

MatthewCroughan commented 3 years ago

Well, that should be it. I always assumed patchShebangs was ran automatically in most cases to fix the issue of hardcoded /usr/bin references, Is this not the case here?

raboof commented 3 years ago

Well, that should be it. I always assumed patchShebangs was ran automatically in most cases to fix the issue of hardcoded /usr/bin references, Is this not the case here?

That should indeed run automatically, but only covers the #! line of executable scripts. In this case 'lpr' was just passed as a parameter to reactor.spawnProcess somewhere inside the python plugin, so that's hard to detect automatically ;)