Skip to content

Bug(?): uv publish fails if unknown files are present in ./dist #8944

Description

@3j14

Description

When a file is created in the ./dist directory before running uv publish, this file causes uv publish to fail. The documentation states that it ignores all other files.

<p>Defaults to the <code>dist</code> directory. Selects only wheels and source distributions, while ignoring other files.</p>

This issue is clearly minor and does not really impact the user much (the error message is quite clear).

However, I think there is no reason to fail if an unknown file is present – as long as a wheel and/or sdist file is found.

If this failure is deliberate, then I would recommend change the documentation.

Steps to reproduce

  1. Build the project (using uv build). The build files will be generated in ./dist.
  2. Create a file in the ./dist directory. On macOS, this could happen e.g. when opening the directory in Finder, which might create the .DS_Store file. Example: touch ./dist/.DS_Store
  3. Run uv publish.

This will fail with the error: error: File is neither a wheel nor a source distribution: 'dist/.DS_Store'

Where does this error come from

The error is raised in uv_publish::files_for_publishing:

let dist_filename = DistFilename::try_from_normalized_filename(&filename)
.ok_or_else(|| PublishError::InvalidFilename(dist.clone()))?;

uv_distribution_filename::DistFilename::try_from_normalized_filename in turn checks if the files are valid wheel or sdist files. Example for wheels:

let stem = filename.strip_suffix(".whl").ok_or_else(|| {
WheelFilenameError::InvalidWheelFileName(
filename.to_string(),
"Must end with .whl".to_string(),
)
})?;

Meta

uv version:

uv 0.5.0 (Homebrew 2024-11-07)

Activity

  1. self-assigned this
    on Nov 8, 2024
  2. charliermarsh commented on Nov 9, 2024

    @charliermarsh
    Member

    Thanks for the report! We'll take a look -- does seem like an oversight.

  3. added
    great writeupA wonderful example of a quality contribution 💜
    on Nov 10, 2024
  4. maliayas commented on Nov 12, 2024

    @maliayas

    I also saw a similar error that may be related when running uv sync. It gave me:

    error: Failed to install: ruff-0.7.3-py3-none-macosx_11_0_arm64.whl (ruff==0.7.3)
      Caused by: The wheel is invalid: Unknown wheel data type: ".DS_Store"
    

    After doing a find . -name .DS_Store -exec rm -rf {} + in /Users/USER/.cache/uv the error was gone.

    P.S. I'm usin uv 0.5.1 (f399a5271 2024-11-08)

  5. charliermarsh commented on Nov 12, 2024

    @charliermarsh
    Member

    Interesting, did you open the uv cache manually at some point?

  6. added a commit that references this issue on Nov 12, 2024
    ecccfa0
  7. maliayas commented on Nov 13, 2024

    @maliayas

    Interesting, did you open the uv cache manually at some point?

    Yes, I inspected it a little bit.

  8. maliayas commented on Nov 13, 2024

    @maliayas

    Is the fix ecccfa0 only for uv publish? FWIW the bug happened to me with uv sync.

  9. konstin commented on Nov 13, 2024

    @konstin
    Member

    @maliayas your case is unrelated to the uv publish case, it looks like the uv cache got corrupted by adding a .DS_Store entry.

  10. added a commit that references this issue on Nov 13, 2024
    926660a
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 workinggreat writeupA wonderful example of a quality contribution 💜

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions