1- diff --git i/conda/__init__.py w/conda/__init__.py
2- index a9970a7a3..a4cf9f0ac 100644
3- --- i/conda/__init__.py
4- +++ w/conda/__init__.py
5- @@ -61,8 +61,11 @@ if os.getenv("CONDA_ROOT") is None:
1+ From 16646a6e08867b48d9f98a7aa0082333fbc0f118 Mon Sep 17 00:00:00 2001
2+ From: jaimergp <jaimergp@users.noreply.github.com>
3+ Date: Wed, 27 Aug 2025 15:45:55 +0200
4+ Subject: [PATCH] Fix conda run
5+
6+ Co-authored-by: Jaida Rice <jaidarice@gmail.com>
7+
8+ ---
9+
10+ diff --git a/conda/__init__.py b/conda/__init__.py
11+ index 3abf5c0da7241d6267b6dd2609fa7f28d4813be5..3805975b1afa0afc528b3d628895836f9905534a 100644
12+ --- a/conda/__init__.py
13+ +++ b/conda/__init__.py
14+ @@ -59,8 +59,11 @@ if os.getenv("CONDA_ROOT") is None:
615 os.environ["CONDA_ROOT"] = sys.prefix
7-
16+
817 #: The conda package directory.
918- CONDA_PACKAGE_ROOT = abspath(dirname(__file__))
1019- #: The path within which to find the conda package.
@@ -16,56 +25,62 @@ index a9970a7a3..a4cf9f0ac 100644
1625 #:
1726 #: If `conda` is statically installed this is the site-packages. If `conda` is an editable install
1827 #: or otherwise uninstalled this is the git repo.
19- diff --git i /conda/activate.py w /conda/activate.py
20- index f3b658470..c406eed9c 100644
21- --- i /conda/activate.py
22- +++ w /conda/activate.py
23- @@ -755 ,6 +755 ,8 @@ class _Activator(metaclass=abc.ABCMeta):
28+ diff --git a /conda/activate.py b /conda/activate.py
29+ index 8b9f17e06d3b2cef8a8804a1c292d3447a4cbcd1..03656c460ec8002097feba19465729a80593cbb9 100644
30+ --- a /conda/activate.py
31+ +++ b /conda/activate.py
32+ @@ -772 ,6 +772 ,8 @@ class _Activator(metaclass=abc.ABCMeta):
2433 return ""
25-
34+
2635 def _get_activate_scripts(self, prefix):
2736+ if prefix is None:
2837+ return ()
2938 _script_extension = self.script_extension
3039 se_len = -len(_script_extension)
3140 try:
32- @@ -769 ,6 +771 ,8 @@ class _Activator(metaclass=abc.ABCMeta):
41+ @@ -786 ,6 +788 ,8 @@ class _Activator(metaclass=abc.ABCMeta):
3342 )
34-
43+
3544 def _get_deactivate_scripts(self, prefix):
3645+ if prefix is None:
3746+ return ()
3847 _script_extension = self.script_extension
3948 se_len = -len(_script_extension)
4049 try:
41- diff --git i /conda/base/context.py w /conda/base/context.py
42- index 34a5e6495..9ac146b2b 100644
43- --- i /conda/base/context.py
44- +++ w /conda/base/context.py
45- @@ -835 ,6 +835 ,8 @@ class Context(Configuration):
50+ diff --git a /conda/base/context.py b /conda/base/context.py
51+ index a8f56f30680d79decfb0e85a9e1ae94257c1c02d..4801003fe35e13209f2a4c27c490efb269c8a592 100644
52+ --- a /conda/base/context.py
53+ +++ b /conda/base/context.py
54+ @@ -846 ,6 +846 ,8 @@ class Context(Configuration):
4655 addendum="Please use `conda.base.context.context.conda_exe_vars_dict` instead",
4756 )
4857 def conda_exe(self) -> PathType:
4958+ if getattr(sys, "_MEIPASS", None):
5059+ return sys.executable
5160 exe = "conda.exe" if on_win else "conda"
5261 return join(self.conda_prefix, BIN_DIRECTORY, exe)
53-
54- @@ -870,9 +872,8 @@ class Context(Configuration):
55- "CONDA_PYTHON_EXE ": sys.executable ,
62+
63+ @@ -885,14 +887,9 @@ class Context(Configuration):
64+ "_CONDA_ROOT ": self.conda_prefix ,
5665 }
5766 else:
58- - exe = "conda.exe" if on_win else "conda"
67+ - exe = os.path.join(
68+ - self.conda_prefix,
69+ - BIN_DIRECTORY,
70+ - "conda.exe" if on_win else "conda",
71+ - )
5972 return {
60- - "CONDA_EXE": os.path.join(sys.prefix, BIN_DIRECTORY, exe),
73+ - "CONDA_EXE": exe,
74+ - "_CONDA_EXE": exe,
6175+ "CONDA_EXE": sys.executable,
76+ + "_CONDA_EXE": sys.executable,
6277 "_CE_M": None,
6378 "_CE_CONDA": None,
6479 "CONDA_PYTHON_EXE": sys.executable,
65- diff --git i /conda/cli/main_run.py w /conda/cli/main_run.py
66- index dc7464662..767fed20d 100644
67- --- i /conda/cli/main_run.py
68- +++ w /conda/cli/main_run.py
80+ diff --git a /conda/cli/main_run.py b /conda/cli/main_run.py
81+ index dc74646620234e206519c26b1e798f96a11a6bd7..767fed20d7f6ccd1032a60caca7ee332c1d0a454 100644
82+ --- a /conda/cli/main_run.py
83+ +++ b /conda/cli/main_run.py
6984@@ -88,11 +88,19 @@ def configure_parser(sub_parsers: _SubParsersAction, **kwargs) -> ArgumentParser
7085 def execute(args: Namespace, parser: ArgumentParser) -> int:
7186 from ..base.context import context
@@ -76,7 +91,7 @@ index dc7464662..767fed20d 100644
7691 from ..gateways.disk.delete import rm_rf
7792 from ..gateways.subprocess import subprocess_call
7893 from ..utils import wrap_subprocess_call
79-
94+
8095+ if paths_equal(context.target_prefix, sys.prefix):
8196+ raise ArgumentError(
8297+ "Cannot use 'conda run' on conda-standalone's base environment; "
@@ -86,14 +101,14 @@ index dc7464662..767fed20d 100644
86101 prefix_data = PrefixData.from_context()
87102 prefix_data.assert_environment()
88103 # create run script
89- diff --git i /conda/utils.py w /conda/utils.py
90- index b9a3cc5cc..515622286 100644
91- --- i /conda/utils.py
92- +++ w /conda/utils.py
104+ diff --git a /conda/utils.py b /conda/utils.py
105+ index b9a3cc5cce027cf38a92efaf6bc81bfaf6d1bd15..515622286f946b4f780da5ecac8812bbb8a87739 100644
106+ --- a /conda/utils.py
107+ +++ b /conda/utils.py
93108@@ -13,7 +13,7 @@ from os.path import abspath, basename, dirname, isfile, join
94109 from pathlib import Path
95110 from shutil import which
96-
111+
97112- from . import CondaError
98113+ from . import CONDA_PACKAGE_ROOT, CondaError
99114 from .auxlib.compat import Utf8NamedTemporaryFile, shlex_split_unicode
0 commit comments