I have two packages that I would like to append to $Path. I have looked at this link for help but after I quit Mathematica, I have to repeat the process again.
Where can I permanently modify $Path?
Is there a way to permanently modify $Path so that I can always access my extra packages?
EDIT: Please this is not a duplicate question or I won't be asking. I tried all the suggestions in that link but they didn't provide a permanent solution. I can't load my packages after I quit Mathematica. I have to go through the whole process again whenever I restart Mathematica.
My init.m file looks like this:
SetOptions[$FrontEnd,
NotebookBrowseDirectory->"/Users/name/Library/Mathematica/mypackages/poma-2.0",
AutoOpenPalettes->{},
Default2DTool->"Select",
Default3DTool->"RotateView",
PrivateFrontEndOptions->{"LicensesAgreed"->{"11.1"}},
VersionsLaunched->{"11.1.1", "11.2.0"},
NotebooksMenu->{"2017_ML" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Desktop",
"2017", "NMR_Workshop_2017"}, "2017_ML.nb",
CharacterEncoding -> "UTF-8"], True, False, True}, "2017_ML" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Desktop",
"2017", "NMR_Workshop_2017", "Malcom_Levitt",
"SpinDynamica_Exercises"}, "2017_ML.nb", CharacterEncoding ->
"UTF-8"], True, False, True}, "A_Problem set I" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Desktop",
"2017", "NMR_Workshop_2017"},
"A_Problem set I.nb", CharacterEncoding -> "UTF-8"], True,
False, True}, "MHL-exercises.nb" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Desktop",
"2017", "NMR_Workshop_2017", "Malcom_Levitt",
"Exercises_ML_2017"}, "MHL-exercises.nb", CharacterEncoding ->
"UTF-8"], True, False, True}, "Levitt_2017" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Desktop",
"2017", "NMR_Workshop_2017"}, "Levitt_2017.nb",
CharacterEncoding -> "UTF-8"], True, False, True}, "Poma2.m" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "programs", "poma-2.0"}, "Poma2.m", CharacterEncoding ->
"UTF-8"], True, False, True}, "Poma2.wl" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "Applications"}, "Poma2.wl", CharacterEncoding ->
"UTF-8"], True, False, True}, "ini.nb" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "mypackages", "SDv3.0.2.2", "SpinDynamica"}, "ini.nb",
CharacterEncoding -> "UTF-8"], True, False, True},
"Untitled-5" -> {"", True, False, True}, "init" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "mypackages", "SDv3.0.2.2", "SpinDynamica"}, "init.nb",
CharacterEncoding -> "UTF-8"], True, False, True}, "init" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "mypackages", "poma-2.0"}, "init.nb",
CharacterEncoding -> "UTF-8"], True, False, True}, "init" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "mypackages", "poma-2.0"}, "init.nb", CharacterEncoding ->
"UTF-8"], True, False, True}, "HMQC.nb" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Downloads"},
"HMQC.nb", CharacterEncoding -> "UTF-8"], True, False, True},
"HMQC" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "mypackages", "poma-2.0"}, "HMQC.nb", CharacterEncoding ->
"UTF-8"], True, False, True}, "hcaco_3d" -> {
FrontEnd`FileName[{$RootDirectory, "Users", "name", "Library",
"Mathematica", "mypackages", "poma-2.0"}, "hcaco_3d.nb",
CharacterEncoding -> "UTF-8"], True, False, True}},
PalettesMenuSettings->{
"BasicMathAssistant.nb" -> {
TaggingRules -> {
"ShowCalculator" -> True, "ShowBasicCommands" -> True,
"ShowBasicTypesetting" -> False, "ShowHelpLinks" -> False,
"PaletteMode" -> 1, "OptionsInsertionMode" -> 1}}},
FindSettings->{"FindBoxes":>"aroma",
"FindString"->"aroma",
"SearchType"->LiteralSearch},
StyleNameDialogSettings->{"Style"->"Title"},
HelpViewerSettings->{"WindowMargins"->{{290, Automatic}, {Automatic, 0}},
"WindowSize"->{860, 796}},
PrivateFrontEndOptions->{"DialogSettings"->{
"Login" -> {"RememberMe" -> True},
"WelcomeScreen" -> {"ShowRecentFilesContextMenu" -> False},
"CustomStyles" -> {WindowMargins -> Automatic},
"Install" -> {"Type" -> "Package"}},
"InterfaceSettings"->{
"PredictiveInterface" -> {"ShowMinimized" -> False, "FirstUse" -> False}},
"WolframAlphaSettings"->{
"Autoload" -> True, "BaseURL" -> "Automatic", "AppID" -> Automatic,
"SendMathematicaSessionInfo" -> Automatic, "Reinterpret" -> True,
"Interactive" -> True, "Language" -> Automatic, "Recalculate" -> True,
"MathematicaFormsFormatType" -> "MostlyInputForm", "Asynchronous" -> True}}
]
The init.nb file which is saved in the sane folder as the package looks like this:
$Path = Append[$Path,
"/Users/name/Library/Mathematica/mypackages/poma-2.0"]
{"/Users/name/Library/Mathematica/DocumentationIndices", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Links", \
"/Users/name/Library/Mathematica/Kernel", \
"/Users/name/Library/Mathematica/Autoload", \
"/Users/name/Library/Mathematica/Applications", \
"/Library/Mathematica/Kernel", "/Library/Mathematica/Autoload", \
"/Library/Mathematica/Applications", ".", "/Users/name", \
"/Applications/Mathematica v 11.2.0.0.app/Contents/AddOns/Packages", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Autoload", \
"/Applications/Mathematica v 11.2.0.0.app/Contents/AddOns/Autoload", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/AddOns/Applications", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/AddOns/ExtraPackages", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Kernel/Packages", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/Documentation/English/System", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Data/ICC", \
"/Users/name/Library/Mathematica/mypackages/poma-2.0", \
"/Users/name/Library/Mathematica/mypackages/poma-2.0"}
If I quit Mathematica and re-open a notebook, path looks like this:
$Path
{"/Users/name/Library/Mathematica/DocumentationIndices", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Links", \
"/Users/name/Library/Mathematica/Kernel", \
"/Users/name/Library/Mathematica/Autoload", \
"/Users/name/Library/Mathematica/Applications", \
"/Library/Mathematica/Kernel", "/Library/Mathematica/Autoload", \
"/Library/Mathematica/Applications", ".", "/Users/name", \
"/Applications/Mathematica v 11.2.0.0.app/Contents/AddOns/Packages", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Autoload", \
"/Applications/Mathematica v 11.2.0.0.app/Contents/AddOns/Autoload", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/AddOns/Applications", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/AddOns/ExtraPackages", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Kernel/Packages", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/Documentation/English/System", \
"/Applications/Mathematica v \
11.2.0.0.app/Contents/SystemFiles/Data/ICC"}
And I can't load the package anymore
<<Poma2.m
Get::noopen: Cannot open Poma2.m.
$Failed
FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}]as Szabolcs proposed. This should take effect after the next kernel restart. Why doesn't it work for you? – Henrik Schumacher Feb 08 '18 at 11:24AppendTo[$ContextPath...line. – Kuba Feb 08 '18 at 13:21FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}]? I have also edited my post to include the init.nb file, which is saved in the same folder as the package. – cave Feb 08 '18 at 14:23FileNameJoin[{$UserBaseDirectory, "FrontEnd", "init.m"}]returns what you claim is inFileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}]. But again, tryPutAppend[ Unevaluated@ AppendTo[$Path, "/Users/name/Library/Mathematica/mypackages/poma-2.0"], FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}] ], quit the kernel and let me know if it works. – Kuba Feb 08 '18 at 17:37AppendTo[$Path, "/Users/name/Library/Mathematica/mypackages/poma-2.0"] AppendTo[$Path, "/Users/name/Library/Mathematica/mypackages/SDv3.0.2.2/SpinDynamica"]Could you please leave your comment as an answer so that it can help others that still have a problem with it? Thanks once again!
– cave Feb 08 '18 at 23:21