I am working on Debian 8 (Jessie) and Mathematica 10.1 (64-bit) Home Edition. I have created a script named curl_fetch.sh. It contains the line:
curl www.google.com > html.txt
Running ./curl_fetch.sh on a terminal I get the HTML output file as expected.
In Mathematica I tried:
SetDirectory[NotebookDirectory[]];
RunProcess["./curl_fetch.sh"]
And I got the file html.txt, but with zero content and the following output:
<|"ExitCode" -> 127, "StandardOutput" -> "",
"StandardError" ->
"curl: /usr/local/Wolfram/Mathematica/10.1/SystemFiles/Libraries/\
Linux-x86-64/libssl.so.1.0.0: no version information available \
(required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
curl: /usr/local/Wolfram/Mathematica/10.1/SystemFiles/Libraries/\
Linux-x86-64/libssl.so.1.0.0: no version information available \
(required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
curl: /usr/local/Wolfram/Mathematica/10.1/SystemFiles/Libraries/\
Linux-x86-64/libcrypto.so.1.0.0: no version information available \
(required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
curl: relocation error: /usr/lib/x86_64-linux-gnu/libcurl.so.4: \
symbol SSL_CTX_set_srp_password, version OPENSSL_1.0.1 not defined in \
file libssl.so.1.0.0 with link time reference
"|>
Why does this happen?
Answer
(Reposting my comment as an answer)
The reason this is happening is that the Mathematica launcher script sets LD_LIBRARY_PATH so that libraries included in the layout will be found and used, and that setting is inherited by any external process started from the kernel. But, sometimes it may happen that the external executable is linked against a conflicting system library.
As a workaround, try evaluating SetEnvironment["LD_LIBRARY_PATH" -> ""] before running the script. The default value could be restored afterwards by
SetEnvironment["LD_LIBRARY_PATH" -> FileNameJoin[{$InstallationDirectory,
"SystemFiles", "Libraries", $SystemID}]]
Probably better and easier, unsetting LD_LIBRARY_PATH could just be done in the script.
Alternatively, one can use the ProcessEnvironment option of RunProcess to pass the desired environment -- for example, the option value could be Association[DeleteCases[GetEnvironment[All], "LD_LIBRARY_PATH" -> _]].
Comments
Post a Comment