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

refer to mamba activate for activation hint #1462

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions mamba/mamba/mamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ensure_name_or_prefix,
specs_from_url,
)
from conda.cli.install import check_prefix, clone, get_revision, print_activate
from conda.cli.install import check_prefix, clone, get_revision
from conda.cli.main import generate_parser, init_loggers
from conda.common.compat import on_win
from conda.common.path import paths_equal
Expand Down Expand Up @@ -50,7 +50,13 @@
from mamba import repoquery as repoquery_api
from mamba.linking import handle_txn
from mamba.mamba_shell_init import shell_init
from mamba.utils import get_installed_jsonfile, init_api_context, load_channels, to_txn
from mamba.utils import (
get_installed_jsonfile,
init_api_context,
load_channels,
print_activate,
to_txn,
)

if sys.version_info < (3, 2):
sys.stdout = codecs.lookup("utf-8")[-1](sys.stdout)
Expand Down Expand Up @@ -898,10 +904,8 @@ def main(*args, **kwargs):

if "activate" in sys.argv or "deactivate" in sys.argv:
print(
f"Run 'mamba init' to be able to run mamba activate/deactivate\n"
f"and start a new shell session. Or use conda to activate/deactivate.\n"
f"\n"
f" $ conda {' '.join(sys.argv[1:])}\n",
"Run 'mamba init' to be able to run mamba activate/deactivate\n"
"and start a new shell session. Or use conda to activate/deactivate.\n",
file=sys.stderr,
)
return sys.exit(-1)
Expand Down
11 changes: 11 additions & 0 deletions mamba/mamba/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,14 @@ def to_txn(
prefix,
final_precs,
)


def print_activate(env_name_or_prefix): # pragma: no cover
if not context.quiet and not context.json:
message = (
"\nTo activate this environment, use\n\n"
f" $ mamba activate {env_name_or_prefix}\n\n"
"To deactivate an active environment, use\n\n"
" $ mamba deactivate\n"
)
print(message) # TODO: use logger