Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following code runs fine if I run it interactively:

realpath[path_] := Import["!readlink "<>path, "Text"];
testsymlink = FileNameJoin[{$HomeDirectory, "testsymlink"}];
test = realpath[testsymlink];

In particular, the variable test gets the expected (non-Null) value.

The same code runs fine also if I put it in a standalone script and execute it with

<< "/path/to/script.m";

But if I put the same code, all by itself, in my Kernel/init.m file, it fails: the variable test gets the incorrect value Null. (The variable testsymlink, on the other hand, is still correctly set.)

Furthermore, if I then evaluate


interactively (in the newly started Mathematica session), I get the error shown in this post's title, twice:

Mathematica graphics

I can't figure out why I'm getting this error, but I'm having it may give someone else a clue as to why the snippet is failing in the first place (when run as part of executing Kernel/init.m.

PS: It appears that the offending snippet puts the session in a corrupted state, because when I attempted to upload the image shown above, I got this error:

Mathematica graphics

I had first restart Mathematica (after deleting the offending snippet from Kernel/init.m), before I could upload these images.

share|improve this question
I looked a bit under the hood by removing Attribute ReadProtected from Import. Interesting, but it didn`t help. – Jacob Akkerboom Jul 25 '13 at 9:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.