question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Push package failed in linux docker when package's icon path contains '\'

See original GitHub issue

Describe the bug

Pushing a package icon path with ‘\’ to baget linux container, will cause System.IO.FileNotFoundException.

fail: BaGet.Core.PackageIndexingService[0]
      Uploaded package is invalid
System.IO.FileNotFoundException: icons\mailkit-50.png
   at NuGet.Packaging.ZipArchiveExtensions.LookupEntry(ZipArchive zipArchive, String path)
   at NuGet.Packaging.ZipArchiveExtensions.OpenFile(ZipArchive zipArchive, String path)
   at NuGet.Packaging.PackageArchiveReader.GetStream(String path)
   at NuGet.Packaging.PackageReaderBase.GetStreamAsync(String path, CancellationToken cancellationToken)
   at BaGet.Core.PackageArchiveReaderExtensions.GetIconAsync(PackageArchiveReader package, CancellationToken cancellationToken) in /src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs:line 54
   at BaGet.Core.PackageIndexingService.IndexAsync(Stream packageStream, CancellationToken cancellationToken) in /src/BaGet.Core/Indexing/PackageIndexingService.cs:line 61

To Reproduce

Steps to reproduce the behavior:

  1. Using latest BaGet image DIGEST ‘3fcb1e9f22c7’
  2. Push MailKit-2.4.1 to BaGet.
  3. See error

Additional context

After some digging, I found something interesting.

According to PackageArchiveReader:

https://github.com/loic-sharma/BaGet/blob/bd440199ba16f62bdb0c157c69b6479f3e2aa9f9/src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs#L50-L55

And Nuget.Packaging:

https://github.com/NuGet/NuGet.Client/blob/e59333e773bbc4fed97e5534fe88e25332ca04b0/src/NuGet.Core/NuGet.Packaging/PackageArchiveReader.cs#L140-L150

        public override Stream GetStream(string path)
        {
            Stream stream = null;
            path = path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
            if (!string.IsNullOrEmpty(path))
            {
                stream = _zipArchive.OpenFile(path);
            }

            return stream;
        }

package.NuspecReader.GetIcon() return icon path in nuspec, it could be window-style or linux-style. When it’s windows-style, and BaGet is running in linux, path = path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); will not replace ‘\’ to ‘/’.

I’m not sure it is a BaGet bug or a Nuget.Packaging bug, any thoughts?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RayMMondcommented, May 27, 2020

Tested OK on latest docker image.

0reactions
aldy505commented, May 5, 2023

Still happening on me. Using the latest image (docker pull loicsharma/baget:0.4.0-preview2).

Stack trace:

 fail: BaGet.Core.PackageIndexingService[0]
       Uploaded package is invalid
 System.IO.FileNotFoundException: docs\README.md
    at NuGet.Packaging.ZipArchiveExtensions.LookupEntry(ZipArchive zipArchive, String path)
    at NuGet.Packaging.ZipArchiveExtensions.OpenFile(ZipArchive zipArchive, String path)
    at NuGet.Packaging.PackageArchiveReader.GetStream(String path)
    at NuGet.Packaging.PackageReaderBase.GetStreamAsync(String path, CancellationToken cancellationToken)
    at BaGet.Core.PackageArchiveReaderExtensions.GetReadmeAsync(PackageArchiveReader package, CancellationToken cancellationToken) in /src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs:line 32
    at BaGet.Core.PackageIndexingService.IndexAsync(Stream packageStream, CancellationToken cancellationToken) in /src/BaGet.Core/Indexing/PackageIndexingService.cs:line 56
Read more comments on GitHub >

github_iconTop Results From Across the Web

Known issues
Find known issues for Docker Desktop.
Read more >
"ERROR: Error response from daemon: ...
The only workaround for me seems "systemctl --user restart docker-desktop" or to restart the whole machine. Ubuntu 22.04.1. Docker version 23.0.
Read more >
An error, "failed to solve with frontend dockerfile.v0"
I had experienced this issue after upgrading to the latest Docker Desktop version on Mac. Solved with the comment on this issue.
Read more >
How to Include Files Outside of Docker's Build Context
As the Dockerfile isn't in the root of the context directory, we provide its path using the -f option. The problem with this...
Read more >
How To Install and Use Docker on Ubuntu 22.04
Step 1 — Installing Docker. The Docker installation package available in the official Ubuntu repository may not be the latest version. To ensure ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found