2

i get the "conda not found issue" after installing conda and i went into my .zshrc to export the path to fix the issue.

I add this line "export PATH=${PATH}:/usr/local/opt/miniconda3/bin" to the .zshrc - still the same issue

When double checking the path i cd to /usr/local first, then i cd into the opt directory, i type ls and it shows nothing. i cd .. back to the local dir and then i ls opt - nothing.

The weird thing is that if i do "ls /opt" i can se miniconda 3, and when i cd /opt and ls I can se miniconda 3. and AFTER i have been in opt this time, if i go back to /local and then cd opt I can ls and se miniconda 3 again.

Output of my terminal after recreating the issue

enter image description here

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
PederF
  • 33
  • 5
  • 1
    It's not recommended to manually change PATH. Have you tried `conda init zsh`, i.e., https://stackoverflow.com/a/55526573/570918? – merv May 03 '21 at 19:25
  • thank you, both solutions worked. But why is it recommended to do it this way instead? conda init gives me a lot of lines in my .zshrc, it seems a lot cleaner to just have the one line that exports the path? Thank you very much! – PederF May 04 '21 at 12:27
  • 2
    Conda is designed to have isolated environments. This is managed by manipulating shell variables (e.g., PATH). Manually adding `bin` to PATH will be outside the scope of the `conda activate` shell functions, and therefore leave the **base** `bin` on PATH even when other environments are activated. This can lead to undefined behavior. For example, leaking environments can lead to cryptic dependencies that one may not realize are being sourced from outside the current environment. Downstream this could mean inadequate documentation of true dependencies and unreproducible code. – merv May 04 '21 at 20:08
  • 3
    Does this answer your question? [How to run Conda?](https://stackoverflow.com/questions/18675907/how-to-run-conda) – Lucas May 05 '21 at 03:49

1 Answers1

0

If directories suddenly disappear and reappear again, I would not worry about a PATH issue. This seems to be the least problem. First of all, from what you wrote, you always have a /opt/miniconda3 directory available (no need to cd into the directory to see this), so I would put into your .zshrc

PATH=$PATH:/opt/miniconda3/bin

and forget about /usr/local.

This should settle your problem with the PATH. If you also want find out, why it sometimes also shows up under /usr/bin and sometimes does not, I would suspect some process is creating a symlink there. It would make sense to monior the directory to find out when this creation happens.

user1934428
  • 19,864
  • 7
  • 42
  • 87
  • It's probably better not to modify the PATH that way, see https://stackoverflow.com/a/55526573. – AMC May 05 '21 at 20:04