Skip to content

Path normilization issue when path has symlink/.. on Linux #175

@nhz2

Description

@nhz2

Minimal Working Example (Linux):

touch test.txt
7z a test.tar test.txt
mkdir foo
mkdir bar
ln -s ../bar foo/bar-sl

Directory structure:

.
├── test.txt
├── test.tar
├── foo
│   └── bar-sl -> ../bar
└── bar

Path resolution check (works correctly)

On Unix, foo/bar-sl/../test.tar resolves to ./test.tar because of quirk in the Unix path design.

The file command correctly handles this:

$ file foo/bar-sl/../test.tar
foo/bar-sl/../test.tar: POSIX tar archive (GNU)

7zip behavior (incorrect)

$ 7z t foo/bar-sl/../test.tar

7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
 64-bit locale=en_US.UTF-8 Threads:16 OPEN_MAX:1024, ASM

Scanning the drive for archives:
1 file, 1536 bytes (2 KiB)

Testing archive: foo/bar-sl/../test.tar
ERROR: foo/bar-sl/../test.tar
Cannot open the file as archive

errno=2 : No such file or directory
    
Can't open as archive: 1
Files: 0
Size:       0
Compressed: 0

It appears that 7zip is normalizing foo/bar-sl/../test.tar as foo/test.tar.

XRef: JuliaLang/julia#60251

As a workaround in JuliaLang/Pkg.jl#4538, realpath is used before passing the path to 7zip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions