Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is really driving me crazy.

In one cell, I change $Path by removing from it un-needed paths that I do not want for the duration of a computation I will be doing.

Immediatly after, in new cell, I type $Path and see it was changed ok.

Now, I open a new cell, and do the same. I type $Path again, and now I see some of the Paths I removed are back again! Here is a screen shot from my notebook now

enter image description here

You can see the variable $Path now has changed, on its own.

This is what I type

$Path =DeleteCases[$Path, "C:\\Users\\me"];
$Path =DeleteCases[$Path, "."];
$Path =DeleteCases[$Path,"C:\\Program Files\\Wolfram Research\\Mathematica\\8.0.4\\AddOns\\LegacyPackages"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Autoload"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Kernel"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Applications"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Applications"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Autoload"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Kernel"];
$Path=DeleteCases[$Path,"C:\\Program Files\\Wolfram

Then in new cell


Then in new cell the same. And now the $Path has been reset.

I noticed this when I was calling Leonid function he posted, and in it, it uses $Path, but I noticed I was getting packages that should not show up since I changed the $Path before calling it.

This is really strange. I am using V 8.0.4 on windows 7


Just installed version 9. Not able to reproduce this. Using the same PC, same notebook, same steps. So it looks like, whatever it was, is fixed in Version 9.

share|improve this question
Regardless of the origin of this, you can use Block[{$Path= DeleteCases[$Path,...]},...] around the function, to get rid of those directories dynamically. – Leonid Shifrin Nov 28 '12 at 18:41
Thanks, Nasser,but my comment does not really explain what you observed, so it won't make a good answer to your question. – Leonid Shifrin Nov 29 '12 at 8:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.