Derivation for Java binary that uses "/usr/bin/lpr"?

I created a package for the PDF editor pdfstudio, which is essentially a Java binary. Everything works fine, except for printing. When I try to print, I get an error message, indicating that it’s trying to use /usr/bin/lpr, which (of course) doesn’t exist:

Caused by: java.io.IOException: Cannot run program “/usr/bin/lpr”: error=2, No such file or directory

Does anybody know how to work around that?

There are a couple of options.

  1. If this is open-source software that your derivation builds from source, you could replace /usr/bin/lpr in the source code with the actual path, e.g. ${pkgs.cups}/bin/lpr.
  2. If this is closed source software, i.e. your derivation packages a pre-made binary, you might need to package it as a FHS sandbox. See for example the lightworks derivation. You would need to include CUPS in targetPkgs, and that way the required binary would be at /usr/bin/lpr (from the application’s point of view), if I’m not mistaken.

If this is closed source software, i.e. your derivation packages a pre-made binary, you might need to package it as a FHS sandbox. See for example the lightworks derivation. You would need to include CUPS in targetPkgs , and that way the required binary would be at /usr/bin/lpr (from the application’s point of view), if I’m not mistaken.

This is exactly what I needed. Thank you!

I have the exact same problem running PDFStudio. Their support since its takeover by Apryse is hopeless. Can you explain how I can get it to print? I don’t know Java, but can bash script.

This has been packaged. I just tested it, and I can print fine using the packaged version of pdfstudio2021… If it doesn’t work for you, can you describe the error you’re getting?

Hi Philipp. Thanks for your reply. I’m struggled to understand what you mean by “the packaged version of pdfstudio2021”. Can you explain? Packaged by whom? I’m running PDFStudio2023.

There is a package in nixpkgs. You can see all versions here: NixOS Search
You should be able to install the package with the nix package manager, e.g., like so:

NIXPKGS_ALLOW_UNFREE=1 nix-env -iA nixpkgs.pdfstudio2021

Or, if you use NixOS, you can add it to your configuration file:

{
...
environment.systemPackages = with pkgs; [ pdfstudio2021 ];
...
}

There are also packages for other versions of PDFStudio, but unfortunately the upstream download link is unstable, and whenever the download link changes, the package breaks. Currently, pdfstudio2023 and pdfstudioviewer are broken, but there is a pull-request that should fix it once it gets merged (see pdfstudioviewer/pdfstudio2023: 2023.0.3->2023.0.4 by PhilippWoelfel · Pull Request #287313 · NixOS/nixpkgs · GitHub)

Hi Philipp,

Thanks again for your reply. I was till now completely ignorant of Nix.I run Debian. I’ll install the package manager and see how I get on with PDFStudio2021.

Regards
Alan