Skip to content

Commit

Permalink
refer to mamba activate for activation hint (#1462)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Feb 9, 2022
1 parent 50ad70e commit d408caf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
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 @@ -900,10 +906,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

0 comments on commit d408caf

Please sign in to comment.