# How to use the Autoload directory?

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? • @Kuba Somehow to me it isn't obvious from that description that the init.m file is required. Normally a package can be loaded with <<Pack  even without an init.m file. But apparently not from Autoload. – Szabolcs May 12 '16 at 12:42 • You should take this topic + symbols lookup + Get with folders + Autoload subtleties and add section "documentation doesn't help either" to your community question about support of packages developement. – Kuba May 12 '16 at 12:52 ## 1 Answer In order for a package in Autoload to load, it must have the file Kernel/init.m. Thus, • Autoload/MyPack.m will not load. • Autoload/MyPack/MyPack.m will 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 Get["MyPackMyPack"]. 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 Autoload/MyPack/init.m, without MyPack/MyPack.m or MyPack/Kernel/init.m. This file could be loaded manually by <<MyPack. This is documented in the most clear way (to me) here in Wolfram System Sessions, which I found through this post. On startup, the Wolfram Language kernel does the following: ... • Loads init.m and Kernel/init.m files in Autoload directories. Notes: • Autoload packages are loaded even when using the -noinit kernel command line option. This makes them different from $UserBaseDirectory/Kernel/init.m, which isn't loaded with -noinit.

Related:

• One can also argue that "Kernel/init.m files in Autoload directories" can be interpreted as $Installation |$UserBase | \$Base / Autoload / Kernel / init.m rather than Autoload / _ / Kernel / init.m. Maybe it's obvious but only if you know it is... When I was learning things from docs I always wondered if strange wording has a purpose or is a result of lack of time of an author. – Kuba May 13 '16 at 6:30