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

stack sdist fails, given a Unicode package name #6372

Closed
mpilgrem opened this issue Dec 10, 2023 · 0 comments
Closed

stack sdist fails, given a Unicode package name #6372

mpilgrem opened this issue Dec 10, 2023 · 0 comments

Comments

@mpilgrem
Copy link
Member

For example, with stack new test١٢٣ and stack sdist .:

Getting the file list for D:\Users\mike\Code\Haskell\test١٢٣\.
test١٢٣> List of package sources written to file
test١٢٣> 'C:\Users\mike\AppData\Local\Temp\stack-sdist-9c8db3646eb70f3f\source-files-list'
Building a compressed archive file in the sdist format for
D:\Users\mike\Code\Haskell\test١٢٣\.
Wrote sdist-format compressed archive to
D:\Users\mike\Code\Haskell\test١٢٣\.stack-work\dist\f1a1ac53\test١٢٣-0.1.0.0.tar.gz.

Error: [S-395]
       Stack looks for packages in the directories configured in the packages and
       extra-deps fields defined in its project-level configuration file (usually
       stack.yaml). The current entry points to
       C:\Users\mike\AppData\Local\Temp\stack-63a2cee6f8c419cf\test١٢٣-0.1.0.0\ but no such
       directory could be found. If, alternatively, a package in the package index was
       intended, its name and version must be specified as an extra-dep.

The problem has its origins in the tar package. Codec.Archive.Tar.Types.fromTarPath uses Data.ByteString.Char8.unpack and so the filepaths encoded with UTF8 are corrupted. Tar is unpacking to C:\Users\mike\AppData\Local\Temp\stack-63a2cee6f8c419cf\test١٢٣-0.1.0.0.

That is, Stack.SDist.withTempTarGzContents fails to behave as expected at the Tar.unpack step:

withTempTarGzContents ::
     Path Abs File
     -- ^ Location of tarball
  -> (Path Abs Dir -> RIO env a)
     -- ^ Perform actions given dir with tarball contents
  -> RIO env a
withTempTarGzContents apath f = withSystemTempDir "stack" $ \tpath -> do
  archive <- liftIO $ L.readFile (toFilePath apath)
  liftIO . Tar.unpack (toFilePath tpath) . Tar.read . GZip.decompress $ archive
  f tpath

Related matters: haskell/cabal#3758 (Lack of support for non-ASCII characters in cabal sdist) and haskell/tar#6 (Paths with unicode characters in them?).

mpilgrem added a commit that referenced this issue Dec 11, 2023
Fix #6372 Allow stack sdist to check packages with non-ASCII names
mpilgrem added a commit that referenced this issue Apr 4, 2024
tar-0.6.2.0 supports Unicode in file names (encoded as UTF-8).

Consequently, Stack no longer needs to UTF-8 encode file names.

Also adds test of `stack sdist .` with Unicode in file names.
mpilgrem added a commit that referenced this issue Apr 5, 2024
tar-0.6.2.0 supports Unicode in file names (encoded as UTF-8).

Consequently, Stack no longer needs to UTF-8 encode file names.

Also adds test of `stack sdist .` with Unicode in file names.
mpilgrem added a commit that referenced this issue Apr 5, 2024
tar-0.6.2.0 supports Unicode in file names (encoded as UTF-8).

Consequently, Stack no longer needs to UTF-8 encode file names.

Also adds test of `stack sdist .` with Unicode in file names.
mpilgrem added a commit that referenced this issue Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant