www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - what am I missing here with that working dir?

reply DFTW <jckj33 gmail.com> writes:
I'd like to call a executable which works fine on terminal if 
called within the bin directory otherwise it give missing issues. 
To archive the same on my D program, I did set the working dir 
but I get an error saying a .so file couldn't be found. What am I 
missing here?

     enum app = 
"/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/bin/wkhtmltopdf";
     enum html = "/path/to/my/htmlFile.htm";
     enum pdf = "/path/to/output/foo.pdf";
     // is this the correct working dir?
     enum workingDir = 
"/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/bin";
     import std.process : execute, Config;
     auto conv = execute([app, html,pdf],
                         null,
                         Config.none,
                         size_t.max,
                         workingDir);
     writeln(conv);

Gives the error:

Tuple!(int, "status", string, "output")(127, 
"/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/bin/wkhtmltopdf" error
while loading shared libraries: libXrender.so.1: cannot open shared object
file: No such file or directory\n")
Mar 15
parent reply FreeSlave <freeslave93 gmail.com> writes:
On Friday, 15 March 2019 at 21:48:50 UTC, DFTW wrote:
 What am I missing here?
Maybe the terminal and your utility you run wkhtmltopdf from have different environment?
Mar 16
parent reply DFTW <jckj33 gmail.com> writes:
On Saturday, 16 March 2019 at 07:27:43 UTC, FreeSlave wrote:
 On Friday, 15 March 2019 at 21:48:50 UTC, DFTW wrote:
 What am I missing here?
Maybe the terminal and your utility you run wkhtmltopdf from have different environment?
I guessed so, I've tried set the env as well: enum env = ["LD_LIBRARY_PATH" : "/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/lib"]; import std.process : execute, Config; auto conv = execute([app, html,pdf], env, Config.newEnv, size_t.max, workingDir); but that doesn't work either.
Mar 18
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Monday, 18 March 2019 at 15:23:46 UTC, DFTW wrote:
 On Saturday, 16 March 2019 at 07:27:43 UTC, FreeSlave wrote:
 On Friday, 15 March 2019 at 21:48:50 UTC, DFTW wrote:
 What am I missing here?
Maybe the terminal and your utility you run wkhtmltopdf from have different environment?
I guessed so, I've tried set the env as well: enum env = ["LD_LIBRARY_PATH" : "/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/lib"]; import std.process : execute, Config; auto conv = execute([app, html,pdf], env, Config.newEnv, size_t.max, workingDir); but that doesn't work either.
My assumption is, the issue is not related to D or the working dir. It is more a linux thing. Maybe you also try function executeShell. Also did you have a look e.g here https://www.google.com/amp/s/www.cyberciti.biz/faq/debian-ubuntu-linux-wkhtmltopdf-error-while-loading-shared-libraries-libxrender-so-1/amp/ Kind regards Andre
Mar 18
next sibling parent Andre Pany <andre s-e-a-p.de> writes:
On Monday, 18 March 2019 at 15:39:39 UTC, Andre Pany wrote:
 On Monday, 18 March 2019 at 15:23:46 UTC, DFTW wrote:
 On Saturday, 16 March 2019 at 07:27:43 UTC, FreeSlave wrote:
 [...]
I guessed so, I've tried set the env as well: enum env = ["LD_LIBRARY_PATH" : "/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/lib"]; import std.process : execute, Config; auto conv = execute([app, html,pdf], env, Config.newEnv, size_t.max, workingDir); but that doesn't work either.
My assumption is, the issue is not related to D or the working dir. It is more a linux thing. Maybe you also try function executeShell. Also did you have a look e.g here https://www.google.com/amp/s/www.cyberciti.biz/faq/debian-ubuntu-linux-wkhtmltopdf-error-while-loading-shared-libraries-libxrender-so-1/amp/ Kind regards Andre
Also did you try, just this command? auto conv = execute([app, html,pdf]); As you use absolute paths, the working directory is not relevant. Kind regards Andre
Mar 18
prev sibling parent DFTW <jckj33 gmail.com> writes:
On Monday, 18 March 2019 at 15:39:39 UTC, Andre Pany wrote:
 On Monday, 18 March 2019 at 15:23:46 UTC, DFTW wrote:
 On Saturday, 16 March 2019 at 07:27:43 UTC, FreeSlave wrote:
 On Friday, 15 March 2019 at 21:48:50 UTC, DFTW wrote:
 What am I missing here?
Maybe the terminal and your utility you run wkhtmltopdf from have different environment?
I guessed so, I've tried set the env as well: enum env = ["LD_LIBRARY_PATH" : "/path/to/wkhtmltox-0.12.4_linux-generic-i386/wkhtmltox/lib"]; import std.process : execute, Config; auto conv = execute([app, html,pdf], env, Config.newEnv, size_t.max, workingDir); but that doesn't work either.
My assumption is, the issue is not related to D or the working dir. It is more a linux thing. Maybe you also try function executeShell. Also did you have a look e.g here https://www.google.com/amp/s/www.cyberciti.biz/faq/debian-ubuntu-linux-wkhtmltopdf-error-while-loading-shared-libraries-libxrender-so-1/amp/ Kind regards Andre
You're right, it's a linux issue. I did get rid of the binaries I've had and compile from the source code on my own, just passing the aditional LD_LIBRARY_PATH set to where the .so files were located, it worked fine!
Mar 18