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 · 35 comments
Closed

make conda work with msysgit terminal or cygwin #747

ijstokes opened this issue May 28, 2014 · 35 comments
Labels
cli pertains to the CLI interface locked [bot] locked due to inactivity type::feature request for a new feature or capability

Comments

@ijstokes
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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

@ijstokes
Copy link
Author

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
Copy link
Contributor

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

@ijstokes
Copy link
Author

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
Copy link
Contributor

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

@ijstokes
Copy link
Author

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

@ijstokes
Copy link
Author

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
Copy link
Contributor

Isn't that issue a duplicate of this one?

@moorepants
Copy link

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
Copy link
Contributor

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

@moorepants
Copy link

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

@asmeurer
Copy link
Contributor

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
Copy link

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
Copy link

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
Copy link
Contributor

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
Copy link

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

@ijstokes
Copy link
Author

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
Copy link

+1

1 similar comment
@nickeubank
Copy link
Contributor

+1

@msarahan
Copy link
Contributor

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
Copy link
Contributor

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

@nickeubank
Copy link
Contributor

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

@ezk84
Copy link

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
Copy link

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
Copy link

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
Copy link

rygo6 commented Feb 1, 2018

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

@mikofski
Copy link

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
Copy link
Contributor

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

@mikofski
Copy link

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 cli pertains to the CLI interface label Mar 13, 2018
@rsheftel
Copy link

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
Copy link

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
Copy link
Contributor

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.

@github-actions
Copy link

github-actions bot commented Sep 4, 2021

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli pertains to the CLI interface locked [bot] locked due to inactivity type::feature request for a new feature or capability
Projects
None yet
Development

No branches or pull requests