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

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

Closed
Tracked by #7839
3j14 opened this issue Nov 8, 2024 · 6 comments · Fixed by #8986
Closed
Tracked by #7839

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

3j14 opened this issue Nov 8, 2024 · 6 comments · Fixed by #8986
Assignees
Labels
bug Something isn't working great writeup A wonderful example of a quality contribution 💜

Comments

@3j14
Copy link

3j14 commented Nov 8, 2024

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)
@konstin konstin self-assigned this Nov 8, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Nov 9, 2024
@charliermarsh
Copy link
Member

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

@konstin konstin added the great writeup A wonderful example of a quality contribution 💜 label Nov 10, 2024
konstin added a commit that referenced this issue Nov 10, 2024
konstin added a commit that referenced this issue Nov 10, 2024
konstin added a commit that referenced this issue Nov 10, 2024
konstin added a commit that referenced this issue Nov 11, 2024
@maliayas
Copy link

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)

@charliermarsh
Copy link
Member

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

konstin added a commit that referenced this issue Nov 12, 2024
@maliayas
Copy link

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

Yes, I inspected it a little bit.

@maliayas
Copy link

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

@konstin
Copy link
Member

konstin commented Nov 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working great writeup A wonderful example of a quality contribution 💜
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants