How can I change the directory of the .condarc file?

Viewed 6099

I need to be able to change the location Anaconda looks at for the .condarc file. The drive it's trying to access doesn't exist anymore and that's causing practically every conda command to fail. I tried uninstalling and reinstalling Anaconda. I also tried conda config --file C:\.condarc

This has been surprisingly difficult to search for - any help would be most appreciated!

2 Answers

I finally got a working solution. It doesn't actually change the location that conda looks to find the .condarc file, but it does work.

Many thanks to nekomatic for the idea!

The %HOME% environment variable was set to H:\ and was being used to find the .condarc file. Though it's probably possible to change the way those variables are set. I instead just mapped my C: drive to H: by assigning H: to \\localhost\C$\

Now.. finally... conda can install things, make environments, etc. I hope this post helps someone else avoid all this frustration.

The answer from @BurntUmber is great if, like me, you'd like to run conda with a temporary .condarc (without messing up the regular ~/.condarc), for example to temporarily set certain channels:

d=$(mktemp -d tmp-conda-config.XXXX)
cat > $d/.condarc <<EOF
channels:
  - s3://mybucket/packages/conda/nightly
  - s3://mybucket/packages/conda/main
  - defaults
channel_priority: true
EOF
rsync -az ~/.aws $d/
HOME=$d conda env create --force -n myenv -f environment.yml

Update

After (re-)reading Conda Configuration Engine for Power Users, the above can be achieved more simply by using CONDARC:

f=$(mktemp condarc-XXXX)
cat > $f << EOF
channels:
  - s3://mybucket/packages/conda/nightly
  - s3://mybucket/packages/conda/main
  - defaults
channel_priority: true
EOF

CONDARC=$f conda env create --force -n myenv -f environment.yml
Related