Skip to content

Empty source tables are not deleted from global configuration file #2034

Closed
@p-rogalski

Description

  • 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. Add a source URL to the global configuration:

    pdm config pypi.custom.url https://test.pypi.org/simple/
  2. Remove the source URL again:

    pdm config pypi.custom.url --delete
  3. The config.toml file now contains an empty table [pypi.custom]:

    [pypi]
    [pypi.custom]
  4. Execute a PDM command in any of your PDM managed projects, e.g. pdm lock

  5. See the error [AssertionError]: Source URL must not be empty:

    PS F:\my-project> pdm lock -v
    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\p.rogalski\.local\bin\pdm.exe\__main__.py", line 7, in <module>
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 289, in main
       return Core().main(args)
             ^^^^^^^^^^^^^^^^^
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 207, in main
       raise cast(Exception, err).with_traceback(traceback) from None
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 202, in main
       self.handle(project, options)
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 157, in handle
       command.handle(project, options)
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\lock.py", line 61, in handle
       actions.do_lock(
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\actions.py", line 70, in do_lock
       provider = project.get_provider(strategy, tracked_names, ignore_compatibility=cross_platform)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       File "C:\Users\p.rogalski\.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\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 393, in get_repository
       sources = self.sources or []
                   ^^^^^^^^^^^^
       File "C:\Users\p.rogalski\.local\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 383, in sources
       assert source.url, "Source URL must not be empty"
    AssertionError: Source URL must not be empty

Actual behavior

PDM errors out on almost any comand, until I manually delete the table [pypi.custom] from C:\Users\p.rogalski\AppData\Local\pdm\pdm\config.toml.

Expected behavior

I should be able to continue working with PDM.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PS F:\my-project> pdm info && pdm info --env
PDM version:
  2.7.4
Python Interpreter:
  F:\my-project\.venv\Scripts\python.exe (3.11-32)
Project Root:
  F:/my-project
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"
}

I had to manually delete the table [pypi.custom] from C:\Users\p.rogalski\AppData\Local\pdm\pdm\config.toml for these commands to work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🐛 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions