Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make conda work with msysgit terminal or cygwin #747

Closed
ijstokes opened this issue May 28, 2014 · 34 comments

Comments

@ijstokes
Copy link
Contributor

@ijstokes ijstokes commented May 28, 2014

The bash shell provided with msysgit (http://msysgit.github.io) or with Cygwin are very useful for people on Windows looking for something more useful than cmd.exe or PowerShell.

However, it appears that at least some of the standard conda commands won't work in this environment (probably not surprisingly), e.g. "activate", since .bat file modification of cmd.exe environment is doubtless different from what a bash shell expects.

It would be nice if this worked. Perhaps just bundling msysgit with Anaconda for Windows would be a good way to provide a "full solution".

@aldanor

This comment has been minimized.

Copy link
Contributor

@aldanor aldanor commented Aug 5, 2014

On a side note: readline-based tools like ipython that get shipped with anaconda windows don't seem to work either

@ijstokes

This comment has been minimized.

Copy link
Contributor Author

@ijstokes ijstokes commented Aug 21, 2014

OK, this is a little "ping" on this issue, with a suggestion that Windows includes an activate script in the Scripts directory that does:

root=/$(conda info | grep 'root env' | cut -f 2- -d ':' | cut -f 1 -d '(' | tr -d ': ' | tr '\\' '/')
envdir=/$(conda info | grep 'envs dir' | cut -f 2- -d ':' | cut -f 1 -d '(' | tr -d ': ' | tr '\\' '/')
excised_path=$(echo $PATH | sed -e "s#:$envdir:#:#g; s#:$envdir/Scripts:#:#g")
export PATH=$envdir/$1:$envdir/Scripts:$excised_path
export PS1="($1) [\u@\h \W]\$ "

I think that will work "well enough"

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Aug 21, 2014

If the msysgit activate script uses bash, can't we just reuse the existing activate script exactly?

@ijstokes

This comment has been minimized.

Copy link
Contributor Author

@ijstokes ijstokes commented Aug 27, 2014

From my experience the last few days it looks like it will actually be more work than I initially suggested. conda install looks like it works, but it doesn't, and I haven't been able to take the time to figure out what is going wrong.

One initial reason that the current script won't work is that programs aren't installed in the same directories. python is in the "top" env directory, not inside of bin, plus there is the Scripts directory that needs to be included in the path.

msysgit bash is pretty good. It would, I think, be a big value-add for our Windows distribution of Anaconda to include some suite of Unix tools (cygwin or msysgit), with appropriate activate scripts, and an environment where conda install works properly.

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Aug 27, 2014

Would it be possible to have a bin/ directory that only gets added to the path on cygwin/msysgit?

@ijstokes

This comment has been minimized.

Copy link
Contributor Author

@ijstokes ijstokes commented Aug 27, 2014

Maybe, but then what about everything that also exists in the "top" directory and in the "Scripts" directory? Are you suggesting that all 3 directories get added to the PATH? (top, Scripts, bin)?

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Aug 27, 2014

Yes, but bin should only be there for bash-like environments.

@ijstokes

This comment has been minimized.

Copy link
Contributor Author

@ijstokes ijstokes commented Sep 15, 2014

Issue #843 is a sub-problem of getting Anaconda on Windows to play nicely with Cygwin or "git bash".

@ijstokes

This comment has been minimized.

Copy link
Contributor Author

@ijstokes ijstokes commented Sep 15, 2014

OK, I understand what you're suggesting: from cygwin/msysgit, there would be 3 directories added to the path:

  1. $ANACONDA/bin
  2. $ANACONDA
  3. $ANACONDA/Scripts

And then the "new" activate (and any other commands that need customization) goes into $ANACONDA/bin and get picked up first, and Anaconda installation looks for the relevant Cygwin/msysgit .profile or .bash_profile etc. files to make the necessary mods.

Sounds like a good plan.

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Sep 15, 2014

Isn't that issue a duplicate of this one?

@moorepants

This comment has been minimized.

Copy link

@moorepants moorepants commented Dec 17, 2014

Ping on this. If you are on windows and need to use unix tools alongside your conda env then it would be ideal to be able to use conda inside the mingw/cygwin shells.

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Dec 17, 2014

Conda itself should work in cygwin if you have the Scripts dir on your PATH. There is no activate script, though.

@moorepants

This comment has been minimized.

Copy link

@moorepants moorepants commented Dec 17, 2014

So how do you activate an environment if you are using the MinGW or Cygwin shell?

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Dec 17, 2014

activating an environment just puts that environment's directory and Scripts directory on the front of the PATH (it also sets CONDA_DEFAULT_ENV so that you don't have to use -n with conda commands).

@moorepants

This comment has been minimized.

Copy link

@moorepants moorepants commented Dec 17, 2014

This is the issue we have: http://stackoverflow.com/questions/24921682/how-to-use-conda-within-cygwin

Should I instruct users to manually use the python in the environment, i.e. type the entire path to the python executable?

@moorepants

This comment has been minimized.

Copy link

@moorepants moorepants commented Dec 17, 2014

I'm trying to write these instructions so that it works cross platform. Currently there are all kinds of issues with Windows but everything works smoothly on Linux/Mac.

@asmeurer

This comment has been minimized.

Copy link
Contributor

@asmeurer asmeurer commented Dec 17, 2014

The simplest solution, if it works, is to recommend using the regular cmd shell on Windows. Otherwise, you can recommend using a full path.

@moorepants

This comment has been minimized.

Copy link

@moorepants moorepants commented Dec 17, 2014

Ok, I'll recommend using the two shells, cmd for conda/python and MinGW/Cygwin for the unix commands.

@ijstokes

This comment has been minimized.

Copy link
Contributor Author

@ijstokes ijstokes commented Oct 7, 2015

@csoja and @ilanschnell I've had some discussions with @stephenakearns and @mrduane about the importance of strong Windows support in Anaconda. I think we're on the same page with @teoliphant @pzwang, MattH and MicheleC. Anaconda (and by implication conda) working wonderfully perfectly in Windows, using Powershell, cygwin, and msysgit (or similar) would really be appreciated.

@dkoppstein

This comment has been minimized.

Copy link

@dkoppstein dkoppstein commented Jan 7, 2016

+1

1 similar comment
@nickeubank

This comment has been minimized.

Copy link
Contributor

@nickeubank nickeubank commented May 1, 2016

+1

@msarahan

This comment has been minimized.

Copy link
Contributor

@msarahan msarahan commented May 1, 2016

This functionality should be present in master as it stands now. We do not have a current release with this yet. It is slated for conda 4.1.

@nickeubank

This comment has been minimized.

Copy link
Contributor

@nickeubank nickeubank commented May 1, 2016

@msarahan Oh great, thank! Do you happen to know if there are any guides to building anaconda from source around?

@nickeubank

This comment has been minimized.

Copy link
Contributor

@nickeubank nickeubank commented May 1, 2016

@msarahan Oh, I see: it's pure python! Ok, I can a python build. Thanks again!

@ezk84

This comment has been minimized.

Copy link

@ezk84 ezk84 commented Mar 6, 2017

Did this functionality make it into conda 4.1 then? I have 4.3 and conda activate inside msysgit screws up my PATH so that none of my normal shell utilities like grep, etc work.

@nirvana-msu

This comment has been minimized.

Copy link

@nirvana-msu nirvana-msu commented Jul 7, 2017

+1, I have exactly same issue. When I try to activate an environment with source activate my-env it screws up PATH which breaks the shell. I'm using Git Bash/MINGW64 on Windows 7 x64.

@bitseer

This comment has been minimized.

Copy link

@bitseer bitseer commented Jul 8, 2017

+1, I'm having the same problem as @nirvana-msu and I'm using cygwin on Windows 10 x64.

@rygo6

This comment has been minimized.

Copy link

@rygo6 rygo6 commented Feb 1, 2018

+1 Really wish I could use anaconda through git bash terminal.

@mikofski

This comment has been minimized.

Copy link

@mikofski mikofski commented Feb 1, 2018

I added the following scripts to the bin folder of my bash shell:

#!/usr/bin/bash
source $LOCALAPPDATA/Continuum/Anaconda3/Scripts/activate "$@"

save this as bin/conda-activate

I also made a path cleaner, saved in bin/rm-anaconda-paths.py:

import os, sys
import logging
logging.basicConfig()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
ANACONDA_LIB_PATH = os.path.expandvars(os.path.join('$LOCALAPPDATA', 'Continuum', 'Anaconda3', 'Library', 'bin')).lower()
LOGGER.debug(ANACONDA_LIB_PATH)
try:
        sys.stdout.write(':'.join('/' + p[0].lower() + p[2:] for p in os.environ['PATH'].split(os.pathsep) if not p.lower().endswith(ANACONDA_LIB_PATH[2:])).replace('\\', '/'))
except Exception as err:
        LOGGER.error(err)
        sys.stdout.write('$PATH')
        sys.exit(-1)
else:
    sys.exit(0)

which I use instead of deactivate here:

#!/usr/bin/bash
source $LOCALAPPDATA/Continuum/anaconda3/Scripts/deactivate
export PATH=`$LOCALAPPDATA/Continuum/anaconda3/python.exe ~/bin/rm-anaconda-paths.py`

saved as bin/conda-deactivate

Never use in a conda-env that has any of the msys channel packages, or path clash hell will ensue. Also, after installing with conda in bash, I have an issue that suddenly bash can't find it anymore and I have to deactivate and re-activate again. 😦

@kalefranz

This comment has been minimized.

Copy link
Member

@kalefranz kalefranz commented Feb 1, 2018

Conda 4.4 should now be compatible with hot bash. Is anybody actually having problems with recent versions of conda 4.4?

@kalefranz kalefranz closed this Feb 1, 2018
@mikofski

This comment has been minimized.

Copy link

@mikofski mikofski commented Feb 1, 2018

I tried to update, but it broke my anaconda, so I downgraded. I'm using 4.3.31 now:

anaconda: 5.0.1-py36h8316230_2 --> custom-py36h363777c_0
conda:    4.3.31-py36_0        --> 4.4.8-py36_0
pycosat:  0.6.2-py36hf17546d_1 --> 0.6.3-py36h413d8a4_0

see this comment

@mbargull mbargull added the tag-shell label Mar 13, 2018
@rsheftel

This comment has been minimized.

Copy link

@rsheftel rsheftel commented Jul 10, 2018

I found this thread when trying to get Cygwin working for conda environment (conda v4.5) when I found in the changelog for v4.4 the answer on how to get it to work which solved the problem for me. Oddly the official documentation has not been updated with this:

https://github.com/conda/conda/blob/master/CHANGELOG.md#recommended-change-to-enable-conda-in-your-shell

@meeotch

This comment has been minimized.

Copy link

@meeotch meeotch commented Jan 26, 2019

I can confirm that conda and cygwin still can't play nicely as of the most recent versions of each. When I attempted, I got the results described here: #7742

The fix referenced by rsheftel above did not fix things for me.

@mingwandroid

This comment has been minimized.

Copy link
Contributor

@mingwandroid mingwandroid commented Jan 26, 2019

Conda well never work very well on Cygwin because Cygwin does not care about interoperation with 'native' Windows software. In fact this is the reason msys was created. I wouldn't recommend using that now-a-days since MSYS2 is available and actually maintained.

If you want basic Cygwin support please submit PRs for this. Conda does support MSYS2 and I will endeavor to make sure this support is maintained as best I can. This MSYS2 support shows what would need to be done to support Cygwin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.