title: Bash script to install conda leads to "conda: command not found" unless I run `bash` at the command line afterwards
body: <p>I'm trying to write a script to install miniConda, then activate a conda environment.</p>
  <p>Here's the relevant part of the code:</p>
  <pre class="lang-sh prettyprint-override"><code>if ! command -v conda --version &amp;&gt; /dev/null
  then
      wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda.sh
      bash conda.sh -b -p ~/local/miniconda3
      rm -f conda.sh
      ~/local/miniconda3/bin/conda init bash
      . ~/.bashrc
  fi
  conda config --set auto_activate_base false
  
  conda create -yn my_env
  eval &quot;$(conda shell.bash hook)&quot;
  conda activate my_env
  </code></pre>
  <p>When I run the script, the output on my terminal looks as though conda was installed successfully. I get a long stream of messages, and, after reading through them all, it seems clear that everything was successful. (It's stuff like <code>Solving environment: done</code>, if that helps).</p>
  <p><b> However, when I run <code>conda --version</code> at my terminal to test if I did install conda, I get the error <code>conda: command not found</code></b></p>
  <p>I can get <code>conda --version</code> to work as expected if I follow <a href="https://stackoverflow.com/questions/35246386/conda-command-not-found/44319368">this</a> StackOverflow answer and type <code>bash</code> into my terminal, then run <code>conda --version</code> from there.</p>
  <p>I've read a lot of answers about shells and subshells and how they relate to conda. I have the vague idea that my issue has to do with something (?) being executed in a subshell instead of the parent shell (?), and maybe something about sourcing <code>~/.bashrc</code> wrong (?). I need some major pointers on the details, though.</p>
  <p><b>I apologize for not being able to form a better question. If I had a more specific idea of what to ask, I would just google it. :) </b></p>
  <p>NOTE: Some of the stuff in my script (like <code>~/local/miniconda3/bin/conda init bash; . ~/.bashrc</code>) was copied from other StackOverflow answers. I read the explanations on those SO questions very carefully, but I unfortunately didn't come away with much more than the general idea &quot;It works if you do this&quot;. It would be great if anyone answering could also explain if those lines relate to my question.</p>