2
$\begingroup$

It seems that URLSave doesn't work as expected with https links in Mathematica 10.4 on Linux. At least in my case (Fedora 30) for

URLSave["https://codeload.github.com/WolframResearch/\
WolframLanguageForJupyter/zip/master", CreateTemporary[]]

I receive

During evaluation of In[1]:= LibraryFunction::libload: The function curlLink_initialize was not loaded from the file /media/Data/Software/Mathematica/10.4/SystemFiles/Links/CURLLink/LibraryResources/Linux-x86-64/libcurllink.so. >>

During evaluation of In[1]:= LibraryFunction::libload: The function curlLink_createHandle was not loaded from the file /media/Data/Software/Mathematica/10.4/SystemFiles/Links/CURLLink/LibraryResources/Linux-x86-64/libcurllink.so. >>

During evaluation of In[1]:= LibraryFunction::libload: The function curlLink_resetHandle was not loaded from the file /media/Data/Software/Mathematica/10.4/SystemFiles/Links/CURLLink/LibraryResources/Linux-x86-64/libcurllink.so. >>

During evaluation of In[1]:= General::stop: Further output of LibraryFunction::libload will be suppressed during this calculation. >>

During evaluation of In[1]:= URLSave::invhttp: CURLLink`CURLError(CURLLink`CURLPerform(CURLLink`CURLHandleLoad())). >>

Out[1]= $Failed

I don't think that WRI is likely to provide support for such an old version, so I'm asking this question in search for some community workarounds.

EDIT: The source of the problem is that for some reason Mma 10 and 11 are not able to load libcurllink.so via

libPath = 
  FileNameJoin[{$InstallationDirectory, "SystemFiles", "Links", 
    "CURLLink", "LibraryResources", "Linux-x86-64", "libcurllink.so"}];
LibraryFunctionLoad[libPath, "curlLink_initialize", {_Integer}, \
"Void"]

Instead, I obtain

LibraryFunction::libload: The function curlLink_initialize was not loaded from the file /media/Data/Software/Mathematica/10.4/SystemFiles/Links/CURLLink/LibraryResources/Linux-x86-64/libcurllink.so. >>

and

LibraryFunction::libload: The function curlLink_initialize was not loaded from the file /media/Data/Software/Mathematica/11.0/SystemFiles/Links/CURLLink/LibraryResources/Linux-x86-64/libcurllink.so.

respectively.

On Mma 11 the workaround would be to use URLDownload which seems to be independent of libcurl and therefore works as expected. On Mma 10 I'm not aware of a such workaround. JLink would be a possibility, but this assumes that one must have Java installed.

$\endgroup$
7
  • $\begingroup$ Your command works on MMA 12 on Win10-64, and I no longer have access to 10.4, so unfortunately I can't reproduce the problem. I would actually think you'd have more luck with Wolfram Support on this one; at least they should be able to figure out what the error means and whether you might be missing some files. Have you checked that you have the files listed in the error messages? $\endgroup$
    – MarcoB
    Commented Jan 6, 2020 at 19:02
  • 2
    $\begingroup$ What does LibraryLink`$LibraryError return? $\endgroup$
    – ilian
    Commented Jan 7, 2020 at 20:00
  • $\begingroup$ @MarcoB Mma 12 has no such issues, this is why I also didn't mention it. Versions 8 and 9 are, however, also affected although in a somewhat different way. The culprit seems to be libcurllink.so. The binaries are the same in Mma 10 and 11, but a newer version is shipped with Mma 12. Effectively this means that MMa 8-10 cannot download anything from the internet on Linux, which is very bad. I wrote to the WRI support, so let us see what they say. $\endgroup$
    – vsht
    Commented Jan 7, 2020 at 20:05
  • $\begingroup$ @ilian You are a genius! It was libidn.so.11: cannot open shared object file: No such file or directory. Obviously because F30 ships only libidn.so.12. So I did sudo ln -s libidn.so.12 libidn.so.11 and now it works with Mma 10 and 11! Thank you so much! Do you by chance also have an idea regarding FetchURL::conopen in Mma 8 and 9? $\endgroup$
    – vsht
    Commented Jan 7, 2020 at 20:13
  • $\begingroup$ That is sudo ln -s /usr/lib64/libidn.so.12 /usr/lib64/libidn.so.11, if someone has similar issues. $\endgroup$
    – vsht
    Commented Jan 7, 2020 at 20:18

1 Answer 1

3
$\begingroup$

The decisive contribution to pin down the issue came from ilian in his comment to my question. He suggested to check the value of LibraryLink`$LibraryError which returned

libidn.so.11: cannot open shared object file: No such file or directory

The reason for this is that Fedora 30 ships libidn.so.12 but Mathematica 10 and 11 explicitly want libidn.so.11. So the simplest workaround is to create the corresponding symlink in /usr/lib64

sudo ln -s /usr/lib64/libidn.so.12 /usr/lib64/libidn.so.11

And voilà, URLSave and all other related functions that rely on libcurllink work again!

All credit goes to ilian for giving me the right pointer straight away.

$\endgroup$
1
  • $\begingroup$ Thank you for writing this up! (+1) $\endgroup$
    – MarcoB
    Commented Jan 7, 2020 at 21:14

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