5
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ @ilian thanks a lot - it worked! Although the solution is just one line it would be nice to have a full answer on details. For example running other commands will I need similar other settings ? $\endgroup$
    – tchronis
    Jul 12, 2015 at 16:40

1 Answer 1

13
$\begingroup$

(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" -> _]].

$\endgroup$
5
  • $\begingroup$ +1 Nice. How do you recover the original environment setting in case something breaks? $\endgroup$
    – tchronis
    Jul 12, 2015 at 17:16
  • $\begingroup$ @tchronis Good point, answer amended. $\endgroup$
    – ilian
    Jul 12, 2015 at 17:55
  • $\begingroup$ @ilian Would you object to my merging this question with the earlier (85291) to move this answer there? It seems to apply equally without modification and I favor older questions in cases like this, all else being equal. $\endgroup$
    – Mr.Wizard
    Jul 13, 2015 at 23:59
  • $\begingroup$ @Mr.Wizard I feel this one is slightly more general and also more likely to be encountered (running curl or maybe ssh as part of a script may be more common than emacs). But I have no objection to merging in any case. $\endgroup$
    – ilian
    Jul 14, 2015 at 0:35
  • $\begingroup$ Okay, I'll trust your judgement on that and join others in voting to close the first one. $\endgroup$
    – Mr.Wizard
    Jul 14, 2015 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.