0

I was trying to add permanently a path inside $Path.

"/Users/Softwares/HEP_Softwares/MT-1.0"

Following $Path manual I did the following

AppendTo[$Path, FileNameJoin[{$HomeDirectory, "/Softwares/HEP_Softwares/MT-1.0""}]];

which does it successfully. However when I quit kernel it goes away. Then following some other Q/A I have messed with something. Now whenever I do to load the package

<<MT` 

it appends the path

/Users/Softwares/HEP_Softwares/MT-1.0 

in \$Path and does not load the package. Is there any way to overcome the situation without changing my previous definitions of \$Path ? Also what is the best way to add a path in $Path permanently? This question may be duplicate but a clear answer is still lacking.

BabaYaga
  • 1,836
  • 9
  • 19
  • Basically following this I messed up https://mathematica.stackexchange.com/questions/165418/how-can-i-globally-change-path-permanently?noredirect=1&lq=1 – BabaYaga May 14 '18 at 14:03
  • Did you modify your kernel init.m as described here? If <<MT` does something expected, check what file it loads using FindFile["MT`"]. – Szabolcs May 14 '18 at 14:10
  • Thanks. I deleted from there. But still in $Path there are 3 such paths exist. How do I remove two of them? – BabaYaga May 14 '18 at 14:13
  • Okay. I found the place. ~/Library/Mathematica/Autoload where other paths are also appended, so there I have put the new path. Also from ~/Library/Mathematica/Autoload/init.m I have removed the extra paths. – BabaYaga May 14 '18 at 14:21
  • I'm sorry but I'm confused about what exactly is the problem, linked topic is what should be done in this case and adding Autoload init.m is an overreaction. If you could elaborate on how your userbase kernel init.m look,s where MT` is, which path you need and what $Path contains in comparison to what do you expect + why linked topic does not work then it will be specific enough to be reopened I guess. I could've missed the point though so let me know if you disagree. – Kuba May 16 '18 at 11:48
  • I agree with you. I had done mistake and somehow the MT path is wrongly put inside Kernel/init.m. So every time I run it appends the MT path in $Path variable. I just wanted mathematica to by default load the MT path without every time setting the MT path. Your solution is right and I just added one solution which I agree kind of overreaction. – BabaYaga May 16 '18 at 12:03

1 Answers1

0

Okay for future reference this could be one answer:

Check the Autoload and Kernel path by $Path.

One can then add the desired PATH (in this case /Users/Softwares/HEP_Softwares/MT ) inside

/Users/Library/Mathematica/Autoload/init.m

For example:

$MTPath = "/Users/Softwares/HEP_Softwares/MT"
If[Not[MemberQ[$Path,$MTPath]],$Path = Flatten[{$Path, $MTPath }]];

Then add the Autoload/init.m in Kernel (if not done already) i.e. in

/Users/Library/Mathematica/Kernel/init.m

by adding the following:

Get[ToFileName["/Users/Library/Mathematica/Autoload","init.m"]]
BabaYaga
  • 1,836
  • 9
  • 19