In a series of QA it has been pointed out that init.m suffers of heavy limitations (see as example, Automatically load packages at startup or Why can't I import a file in the init.m file?:

"As you correctly suggested init.m is read early in the setup when the kernel not yet can make full use of all these features and thus it just isn't the right place to do that."

"Thus I would not suggest to make an import part of an init.m even if it would work, except you really enjoy the meditative tranquility when waiting for the kernel to start up :-)." )

Now, the problem is that I have a large set of functions, not inteded for computation, rather to add additional features to my workspace (autosaving notebook in the appropriate directory, or autologging the activities carried out, ...), doesn't fitting well the init.m environment.

Up to now I have circumvented the obstacle launching Mathematica, by a click on NotebookInitialize.nb, who contains an initialization cell


and it has been proven a passable technique, except that, obviously, it is not triggered when Mathematica is started clicking on any other document. Surely, an annoying situation.

Therefore a general question arises: what's the way to load a large package everytime Mathematica starts ?


An good answer to this question was given in Possible Bug of loading Package @ Mathematica 10.1 :

task := Get["package`"];
time = 1;
RunScheduledTask[task, {time}];

The trick is suitable, assuming that: (1) the interval time is sufficiently long to let the initialization end (2) the RunScheduledTask function is available while initialization is still runnning (indeed, RunScheduledTask is its last command).

These conditions could in principle depend from Matheatica's version and hardawre/OS system, therefore, although the advice above is extremely astute and useful, a bit of uncertainty still remains about programmatically detecting the end of startup phase.

  • 1
    $\begingroup$ closely related: 110243 + the one with a workaround you need: 84589 $\endgroup$
    – Kuba
    Commented May 6, 2016 at 6:45
  • $\begingroup$ Please, see the addendum placed at the bottom of the question. $\endgroup$ Commented May 6, 2016 at 12:53


Browse other questions tagged or ask your own question.