According to the documentation, packages in
$UserBaseDirectory/Autoload will load automatically on startup. I placed an
.m file in this directory and it did not get loaded. How can I get this to work?
In order for a package in
Autoload to load, it must have the file
Autoload/MyPack.mwill not load.
Autoload/MyPack/MyPack.mwill also not load.
Instead, we need to have the following structure:
A package file at
Autoload/MyPack/Mypack.m and an initialization file for the package at
Autoload/MyPack/Kernel/init.m, containing the usual
This is the standard application structure. However, in other situations, simple packages can also be contained in a single
.m file, without needing to have a separate directory and
init.m for them, so I was surprised that that structure didn't work.
For very small packages which are really just meant to be used as initialization code, we can also use a single file placed at
MyPack/Kernel/init.m. This file could be loaded manually by
On startup, the Wolfram Language kernel does the following:
Kernel/init.mfiles in Autoload directories.
- Autoload packages are loaded even when using the
-noinitkernel command line option. This makes them different from
$UserBaseDirectory/Kernel/init.m, which isn't loaded with