I am trying to use the Master Packages discussion from "Programming in Mathematica" by Roman Maeder.

I have a directory:

D:\at_work\mathematica\JacksPackages


that contains five packages:

importMatlab.m
lintran.m
mrxUtilities.m
nmrCalc.m
oilHydrogenIndex.m


I ran MakeMaster.m and it produced an init.m file in my local directory that has these lines:

BeginPackage["init"]
EndPackage[]

DeclarePackage["importMatlab", {"dataNames", "dataValues", "fixData", "importMatlab"}]

DeclarePackage["lintran", {"lintran"}]

DeclarePackage["mrxUtilities", {"mrxWindowBorders"}]

DeclarePackage["nmrCalc", {"dcgas", "dcOilVis", "dcwat", "fgor", "lambda", "t1gas", "t1gas$", "t1OilVis", "visOilDC", "visOilT1"}] DeclarePackage["oilHydrogenIndex", {"apiSgoil", "hiOil", "hiOilCragoe", "hiOilKleinberg", "hiOilSaraband", "molWtCragoe", "oilVisDens", "sgoilApi"}] Null  According to the book if I create an initialization file that contains, Needs["directory"], Mathematics searches the given directory first for Kernel/init.m and then for init.m and loads the first file found. I went to my$UserBaseDirectory\kernel and created a init.m file there that has these lines:

(** User Mathematica initialization file **)

$Path = Flatten[{$Path[[1 ;; 2]], "D:\\at_work\\mathematica\\JacksPackages", \$Path[[3 ;; -1]]}]

Needs["JacksPackages"];


It doesn't work. I modified the directory that I added to the path to be:

"D:\\at_work\\mathematica"


It also doesn't work.

My local directory has no Kernel subfolder.

To the best of my knowledge I am following the procedure but with no success.

Would be greatful if someone could point out the mistake I am making.

I expressly don't want to use one of Mathmematica's predefined files on the search path.

• Just a thought: Maybe lazy-loading is not really necessary these days because computers are fast enough. Even if you load the entire package at once, it won't take that long. (I do realize that there can be many exceptions to that, in particular when loading the package doesn't just create definitions but actually does something.) – Szabolcs Jan 8 at 12:07