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

Index configuration merging failing with "Source URL must not be empty" #2130

Closed
1 task done
p-rogalski opened this issue Jul 25, 2023 · 0 comments · Fixed by #2131
Closed
1 task done

Index configuration merging failing with "Source URL must not be empty" #2130

p-rogalski opened this issue Jul 25, 2023 · 0 comments · Fixed by #2131
Assignees
Labels
🐛 bug Something isn't working

Comments

@p-rogalski
Copy link
Contributor

p-rogalski commented Jul 25, 2023

  • 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

  1. Generate a PDM project which uses a custom index
    Set-up the index configuration like described in the docs (name + url in pyproject.toml, username + password in the config file)
  2. Generate a second PDM project which does not use the custom index
  3. Use PDM commands (like pdm install) in the second PDM project
  4. Observe AssertionError: Source URL must not be empty for <custom_index>

Actual behavior

Traceback

pdm install -v
Lock file hash doesn't match pyproject.toml, packages may be outdated
Updating the lock file...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\<username>\.local\bin\pdm.exe\__main__.py", line 7, in <module>
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 203, in main
    self.handle(project, options)
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 157, in handle
    command.handle(project, options)
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\install.py", line 85, in handle
    actions.do_lock(
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\actions.py", line 78, in do_lock
    provider = project.get_provider(strategy, tracked_names, ignore_compatibility=cross_platform)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 426, in get_provider
    repository = self.get_repository(ignore_compatibility=ignore_compatibility)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 393, in get_repository
    sources = self.sources or []
              ^^^^^^^^^^^^
  File "C:\Users\<username>\.local\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 383, in sources
    assert source.url, f"Source URL must not be empty for {source.name}"
AssertionError: Source URL must not be empty for <custom_index>

I believe this happens, because the URL of the custom index is neither stored in the config file, nor stored in the pyproject.toml file of the second PDM project. Therefore, the index configuration merging logic fails.

This can be mitigated by storing the URL in the config file as well, but this defeats the purpose of index configuration merging IMO.

Expected behavior

There should be no error in the second project. The custom index should be skipped, because it is not used.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:

PDM version:
  2.8.0
Python Interpreter:
  F:\python-pdm\.venv\Scripts\python.exe (3.11-32)
Project Root:
  F:/python-pdm
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.2",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.22621",
  "python_full_version": "3.11.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}
@p-rogalski p-rogalski added the 🐛 bug Something isn't working label Jul 25, 2023
@frostming frostming self-assigned this Jul 25, 2023
frostming added a commit that referenced this issue Jul 25, 2023
Fixes #2130

Signed-off-by: Frost Ming <me@frostming.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants