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

Micromamba >v1.4.5 broken with cygwin #2683

Closed
2 tasks done
0xbe7a opened this issue Jul 17, 2023 · 22 comments · Fixed by #2685 or #2803
Closed
2 tasks done

Micromamba >v1.4.5 broken with cygwin #2683

0xbe7a opened this issue Jul 17, 2023 · 22 comments · Fixed by #2685 or #2803
Assignees

Comments

@0xbe7a
Copy link
Contributor

0xbe7a commented Jul 17, 2023

Troubleshooting docs

  • My problem is not solved in the Troubleshooting docs

How did you install Mamba?

Micromamba

Search tried in issue tracker

yes

Latest version of Mamba

  • My problem is not solved with the latest version

Tried in Conda?

Not applicable

Describe your issue

I'm using micromamba with cygwin. My .bash_profile looks like

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/cygdrive/c/Users/USER/.bin/micromamba.exe';
export MAMBA_ROOT_PREFIX='/cygdrive/c/Users/USER/micromamba_prefix';
eval "$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX")"
# <<< mamba initialize <<<

With micromamba <=1.4.5 shell hook --shell bash checked if !hook_source_path().empty() and if true just emitted the file shell hook without substituting $MAMBA_EXE. Only if hook_source_path() was empty would get_hook_contents be used to emit the shell hook. Crucially get_hook_contents replaced $MAMBA_EXE with the path to the binary on its own. However, this produces a broken config, as the replaced path is in windows format which cant be opened by cygwins bash. PR #2631 changed the behavior of shell hook so that get_hook_contents is always used which breaks my cygwin config.

I'm not really sure how to tackle this problem, but i think a --no-replace option for shell hook would solve my issue.

mamba info / micromamba info

No response

Logs

No response

environment.yml

No response

~/.condarc

No response

@0xbe7a 0xbe7a changed the title >Micromamba v1.4.5 broken with cygwin Micromamba >v1.4.5 broken with cygwin Jul 17, 2023
@jonashaag
Copy link
Contributor

I think we should use the equivalent of cygpath -u for get_hook_contents in bash

@jonashaag
Copy link
Contributor

I wonder why this hasn't been found in the tests.

@AntoinePrv
Copy link
Member

Thank you for reporting @0xbe7a

If I understand correctly, the issue can be solved by using /unix/like/paths?
More precisely changing the format here?
I think it is safe to make it always unix-like when using unix shells.

@AntoinePrv AntoinePrv self-assigned this Jul 18, 2023
@0xbe7a
Copy link
Contributor Author

0xbe7a commented Jul 18, 2023

Yes, i think the assumption should hold in general and would solve my issue!

@AntoinePrv
Copy link
Member

@0xbe7a could you try #2685 locally?

@0xbe7a
Copy link
Contributor Author

0xbe7a commented Jul 18, 2023

I can't build micromamba in the enterprise environment im in. I could test out the artifacts from the CI builds, however the CI Build micromamba - win-64 is failing

@AntoinePrv
Copy link
Member

I could test out the artifacts from the CI builds, however the CI Build micromamba - win-64 is failing

That should be a temporary VCPKG issue 🤞

@pavelzw
Copy link
Member

pavelzw commented Jul 18, 2023

That should be a temporary VCPKG issue 🤞

Let's hope microsoft/vcpkg#32600 is fixed soon 😅

@0xbe7a
Copy link
Contributor Author

0xbe7a commented Jul 19, 2023

The PR still replaces the $MAMBA_EXE with a path in windows format

~ $ micromamba shell hook --shell=bash micromamba_prefix/

# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause

__mamba_exe() (
    "C:\Users\USER\micromamba.exe" "${@}"
)

After discovering more issues with cygwins cygdrive i abandonned cygwin for gits bash.exe. gits bash.exe can handle paths in windows format so micromamba 1.4.9 works.

@0xbe7a 0xbe7a closed this as completed Jul 19, 2023
@jonashaag jonashaag reopened this Jul 19, 2023
@jonashaag
Copy link
Contributor

I'll reopen because it's not fixed.

@goyalyashpal
Copy link

as this is related with unix shells on windows, saying just for recrods; that micromamba 1.4.9 works fine with msys2 3.4.7.x86_64.

@vickunwu
Copy link

as this is related with unix shells on windows, saying just for recrods; that micromamba 1.4.9 works fine with msys2 3.4.7.x86_64.

@goyalyashpal Hello friend. I'm using msys2 with zsh as shell(not Git Bash) but I cannot get micromamba working. Could you please give me some instructions about the details of how to make it run? Appreciate it a lot.

@goyalyashpal
Copy link

goyalyashpal commented Nov 27, 2023

I'm using msys2 with zsh as shell(not Git Bash) but I cannot get micromamba working

hi! i may have helped, but i don't have enough information. read here: https://tinyurl.com/stack-checklist/ and here: http://catb.org/~esr/faqs/smart-questions.html#beprecise

@vickunwu
Copy link

I'm using msys2 with zsh as shell(not Git Bash) but I cannot get micromamba working

hi! i may have helped, but i don't have enough information. read here: https://tinyurl.com/stack-checklist/

@goyalyashpal
I've managed to get the micromamba auto completion works by modifying the following line in my rc file:
eval "$("$MAMBA_EXE" shell hook --shell ${SHELL##*/} --root-prefix "$MAMBA_ROOT_PREFIX" | sed "s#$(cygpath -w $MAMBA_EXE|sed 's|\\|\\\\|g')#$MAMBA_EXE#g")"

The reason I did this is that msys2 do not recognize windows path (e.g. 'C:\micromamba\micromamba.exe') that called in the shell hook.

But when I tried to activate a certain env, here's the output:

(eval):.:7: no such file or directory: C:\Users\vickunwu\scoop\persist\micromamba\mamba\envs\whisperx\etc\conda\activate.d\openssl_activate.sh^M

I guess it's the same issue but this time I'm not able to do hacks anymore as it's controlled by the program.

@goyalyashpal
Copy link

goyalyashpal commented Nov 27, 2023

micromamba auto completion works
I tried to activate a certain env, here's the output:

$ micromamba activate 
critical libmamba Shell not initialized

'micromamba' is running as a subprocess and can't modify the parent shell. 
Thus you must initialize your shell before using activate and deactivate.  

To initialize the current bash shell, run:
    $ eval "$(micromamba shell hook --shell bash)"
and then activate or deactivate with:
    $ micromamba activate
To automatically initialize all future (bash) shells, run:
    $ micromamba shell init --shell bash --root-prefix=~/micromamba        
If your shell was already initialized, reinitialize your shell with:       
    $ micromamba shell reinit --shell bash
Otherwise, this may be an issue. In the meantime you can run commands. See:
    $ micromamba run --help

Supported shells are {bash, zsh, csh, xonsh, cmd.exe, powershell, fish}.   

$ eval "$(micromamba shell hook --shell bash)"

$ micromamba activate 
warning  libmamba 'root_prefix' set with default value: C:\Users\...\micromamba
(base) 
$

sed 's|\\|\\\\|g'

why not use forward slashes?

@vickunwu
Copy link

@goyalyashpal

why not use forward slashes?

I'm not clear about where should I use forward slashes. I think '' should be processed as it's an escape character.

Here's my output of executing eval "$(micromamba shell hook -s bash)"

eval "$(micromamba shell hook -s bash)"
zsh: parse error near `^M'

I'm using msys_shell.cmd to spawn a mingw64 session in Windows terminal. Does this make a difference?

I think the output is a CRLF/LF issue. However, as the shell hook contains lines like \return, I cannot just tr -d '\r' or sed 's/\r//g'.

I've tried dos2unix but it still messes the shell hook.

@goyalyashpal
Copy link

goyalyashpal commented Nov 27, 2023

msys_shell.cmd to spawn a mingw64 session in Windows terminal

that script is no longer required as there are dedicated .exe launchers now.

but i launch the bash session directly from konsole or wezterm terminal. konsole allows picking default shell in its settings - i picked bash there.

i have faint memory that there probably were some problems on invoking from cmd, but can't say for sure


also, have u tried invoking activation command from bash?

@goyalyashpal
Copy link

scoop\persist\micromamba\mamba\envs

i installed micromamba directly - without using scoop. just guessing here - that as scoop is windows only, and u seemed to be facing errors in that direction - so, maybe try direct install of micromamba too.

https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html#umamba-install

@vickunwu
Copy link

also, have u tried invoking activation command from bash?

I tried bash this time, and it works on both launcher and cmd without any problem. I guess that's a zsh issue.
Thanks for your kind assistance!


I'm sad to say that I use Msys2 mainly because it's native support for zsh. Otherwise, I would rather use Git Bash as it seems to have less compatibility issues.

Maybe I should open another issue.

@goyalyashpal

This comment was marked as off-topic.

@vickunwu

This comment was marked as off-topic.

@ThomasMarwitzQC
Copy link

@0xbe7a and I discovered a quick fix that you can use as long as this is not fixed and you don't want to abandon Cygwin:

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/cygdrive/c/Users/thomas/.bin/micromamba';
export MAMBA_ROOT_PREFIX='/cygdrive/c/Users/thomas/micromamba_prefix';
eval "$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX")"
# <<< mamba initialize <<<

__mamba_exe() (
    "${MAMBA_EXE}" "${@}"
)

micromamba activate base

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants