0

Path of my Anaconda3 folder:

  C:\Users\shail\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)

Commands tried in Git bash terminal:

  conda init bash
  echo '. ${HOME}/.bash_profile' >> ~/.bashrc 
  base *c:\Users\shail\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)

Error:

  bash: syntax error near unexpected token '(' #on using the base command

I have read many blogs but all the codes are mostly outdated and do not work for me. Pls guide. I have anaconda installed which workd perfectly on cmd terminal and anaconda prompt but I am unable to access anaconda in git bash.

noob
  • 3,601
  • 6
  • 27
  • 73

2 Answers2

2

Whenever you set a path for local environment variable, ideally make sure that the path does not have spaces or special characters: (, ), !, $, & etc.

If this cannot be avoided, you can solve this by searching environment in windows search -> Select Environment Variables -> Double click on Path -> Look for the path you have mentioned above and change it whatever folder conda.exe is located in. If in path, this location is not there, add it. Also, add the scripts in Anaconda/scripts to your path.

If this doesn't work, some people have found workarounds here.

2

You need quotes around $HOME if it contains any shell special characters.

echo '. "$HOME"/.bash_profile'>>~/.bashrc

Equivalently, use ~ without quotes, just like you already do in ~/.bashrc

Either way, obviously take out the old erroneous assignment from .bashrc, too.

The braces around ${HOME} did no harm, but also don't contribute anything useful (braces are useful when you need to interpolate a variable net to verbatim text, like ${HOME}LY which means the value of HOME next to the literal text LY, as opposed to $HOMELY which would attempt yo expand a variable with that name, which produces an empty string if the variable doesn't exist).

tripleee
  • 175,061
  • 34
  • 275
  • 318