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

unexpected --prompt arg in conda create #1734

Closed
1 task done
Well2333 opened this issue Feb 23, 2023 · 3 comments · Fixed by j178/pdm#1
Closed
1 task done

unexpected --prompt arg in conda create #1734

Well2333 opened this issue Feb 23, 2023 · 3 comments · Fixed by j178/pdm#1
Labels
🐛 bug Something isn't working 💝 good first issue Good for newcomers ❓ help wanted Extra attention is needed

Comments

@Well2333
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Following the approach in the documentation, I chose to use conda as the virtual environment by running following commands

pdm config venv.backend conda

and then install my project

pdm install

Actual behavior

(base) PS C:\github\VoiceS> pdm install -v
STATUS: Resolving packages from lockfile...
python.use_venv is on, creating a virtualenv for this         
project...
'C:\\github\\VoiceS\\.venv', 'python=3.9', 
'--prompt=voices-3.9']
C:\Users\Well404\miniconda3\lib\site-packages\requests\__init__.py:102: RequestsDependencyWarning: urllib3 (1.26.8) or chardet (5.1.0)/charset_normalizer (2.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn't match a supported "
usage: conda-script.py [-h] [-V] command ...
conda-script.py: error: unrecognized arguments: --prompt=voice[VirtualenvCreateError]: Command '['conda', 'create', '--yes','--prefix', 'C:\\github\\VoiceS\\.venv', 'python=3.9',        
'--prompt=voices-3.9']' returned non-zero exit status 2.
pdm.termui: Error occurs
Traceback (most recent call last):
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\termui.py", line 240, in logging
    yield logger
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\cli\actions.py", line 140, in resolve_candidates_from_lockfile
    provider = project.get_provider(for_install=True)
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 422, in get_provider
    repository = self.get_repository(ignore_compatibility=ignore_compatibility)
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 390, in get_repository
    return cls(sources, self.environment, ignore_compatibility=ignore_compatibility)
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 259, in environment
    self._environment = self.get_environment()
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 237, in get_environment
    and get_venv_like_prefix(self.python.executable) is not None
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 149, in python
    self._python = self.resolve_interpreter()
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 205, in resolve_interpreter
    venv = self._create_virtualenv()
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\project\core.py", line 246, in _create_virtualenv
    path = venv_backend.create(
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\cli\commands\venv\backends.py", line 120, in create
    self.perform_create(location, args)
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\cli\commands\venv\backends.py", line 196, in perform_create
    self.subprocess_call(cmd)
  File "C:\Users\Well404\AppData\Roaming\pdm\venv\lib\site-packages\pdm\cli\commands\venv\backends.py", line 75, in subprocess_call
    raise VirtualenvCreateError(e) from None
pdm.cli.commands.venv.backends.VirtualenvCreateError: Command '['conda', 'create', '--yes', '--prefix', 'C:\\github\\VoiceS\\.venv', 'python=3.9', '--prompt=voices-3.9']' returned non-zero exit status 2.

Expected behavior

arg --prompt is not available in miniconda3(documentation) which scripts is using now

Environment Information

Information for this command cannot be provided because the installation does not work properly.

The environment variables of PDM are provided here, might be help.

Site/default configuration 
(C:\ProgramData\pdm\pdm\config.toml):
build_isolation = True
cache_dir = C:\Users\Well404\AppData\Local\pdm\pdm\Cache      
check_update = True
global_project.fallback = False
global_project.fallback_verbose = True
global_project.path =
C:\Users\Well404\AppData\Local\pdm\pdm\global-project
global_project.user_site = False
install.cache = False
install.cache_method = symlink
install.parallel = True
project_max_depth = 5
pypi.ignore_stored_index = False
pypi.json_api = False
pypi.url = https://pypi.org/simple
pypi.verify_ssl = True
python.use_pyenv = True
python.use_venv = True
strategy.resolve_max_rounds = 10000
strategy.save = minimum
strategy.update = reuse
theme.error = red
theme.info = blue
theme.primary = cyan
theme.req = bold green
theme.success = green
theme.warning = yellow
venv.backend = virtualenv
venv.in_project = True
venv.location = C:\Users\Well404\AppData\Local\pdm\pdm\venvs  
venv.prompt = {project_name}-{python_version}
venv.with_pip = False

Home configuration 
(C:\Users\Well404\AppData\Local\pdm\pdm\config.toml):
pypi.password = <hidden>
pypi.username = Well404
repository.pypi.url = https://upload.pypi.org/legacy/
repository.pypi.username = Well404
repository.pypi.password = <hidden>
venv.backend = conda
@Well2333 Well2333 added the 🐛 bug Something isn't working label Feb 23, 2023
@Well2333
Copy link
Author

Well2333 commented Feb 23, 2023

简单概括一下
在使用 conda 作为虚拟环境的时候 pdm install 依然在创建环境时添加了 --prompt 作为参数,在 miniconda 的文档中可用看到 --prompt 并不是 conda 支持的参数,因此出现了错误。

@Well2333
Copy link
Author

@ProgramRipper
Copy link
Contributor

prompt is managed by conda and seems difficult to change, so perhaps we should just ignore venv.prompt when using conda?

diff --git a/src/pdm/cli/commands/venv/backends.py b/src/pdm/cli/commands/venv/backends.py
index 829e9bc5..f34ce907 100644
--- a/src/pdm/cli/commands/venv/backends.py
+++ b/src/pdm/cli/commands/venv/backends.py
@@ -100,7 +100,7 @@ class Backend(abc.ABC):
         else:
             location = self.get_location(name)
         args = (*self.pip_args(with_pip), *args)
-        if prompt is not None:
+        if prompt is not None and not isinstance(self, CondaBackend):
             prompt_string = prompt.format(
                 project_name=self.project.root.name.lower() or "virtualenv",

@frostming frostming added ❓ help wanted Extra attention is needed 💝 good first issue Good for newcomers labels Feb 25, 2023
frostming added a commit that referenced this issue Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 💝 good first issue Good for newcomers ❓ help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants