Parallel kernels are not reading the init.m files in $UserBaseDirectory/Autoload since version 11.2. The master kernel reads it fine. In earlier versions of Mathematica parallel kernels read these init.m files. Any suggestions?

  • $\begingroup$ I don't have v9.0 here, but in 10.0 and later init.m is definitely not evaluated on parallel kernels. $\endgroup$ – Szabolcs Jan 17 '18 at 16:39
  • $\begingroup$ I believe it worked from FileNameJoin[{$InstallationDirectory, "AddOns", "Autoload", "Kernel", "init.m"}] in 11.0 and 11.1. The key could be the Autoload part. I realise this is a non-standard (or very old) location but it worked, up until 11.2. $\endgroup$ – Chris Degnen Jan 17 '18 at 16:57
  • $\begingroup$ I think that's an incorrect use of the Autoload directory. It should contain packages, not Kernel/init.m. A package itself may (and should) contain a Kernel/init.m. This init.m has nothing to do with $UserBaseDirectory/Kernel/init.m—it's not an alternative for it. When you put Kernel/init.m in Autoload it considered that a package. $\endgroup$ – Szabolcs Jan 17 '18 at 17:55
  • $\begingroup$ All that said, it does appear that subkernels stopped loading autoload packages in 11.2, so the solution I suggested no longer works. I think I'll ask support about this because I don't know any other reasonable way to run initialization code on subkernels. $\endgroup$ – Szabolcs Jan 17 '18 at 17:56
  • $\begingroup$ The sysinit.m file used to have a check for the -noinit option, which would control if Kernel/init.m should load. It also contained the code to load Autoload stuff (unconditionally). None of this is present in sysinit.m anymore in 11.2. These files must be loading by another mechanism. $\endgroup$ – Szabolcs Jan 17 '18 at 18:05

This works


c/o Register "initialization code" to run on any newly started parallel kernel

However, it is undocumented.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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