Skip to content

Unable to find symlink destination #4776

Closed

Description

@fosskers

General summary/comments

stack on master seems to be having trouble locating a symlink target that definitely does exist.

colin@yumi ~/c/h/chainweb> stack test
Cloning 37ad6ebb25c975c3c0ab9d5554cd5fb6d4809da8 from https://github.com/kadena-io/pact.git
Unsupported tarball from /tmp/with-repo-archive16624/foo.tar: Symbolic link dest not found from docs/en/img to ../img, looking for docs/img.

docs/img/ does exist (it's a directory).

Steps to reproduce

For example:

  1. Clone this branch
  2. stack build
  3. See the error I pasted above.

Expected

The pinned dependency on Pact is pulled and built.

Actual

stack fails somewhere between pulling and building.

Stack version

Version 2.0.0, Git revision dfbf85ad7e8af5b01cf7b51367290870ffc2c90e x86_64 hpack-0.31.1

Method of installation

A very recent stack upgrade --git.

Activity

  1. fosskers commented on Apr 25, 2019

    @fosskers
    ContributorAuthor

    The message comes from:

    Nothing -> Left $ "Symbolic link dest not found from " ++ mePath me ++ " to " ++ relDest ++ ", looking for " ++ dest ++ ".\n"

  2. fosskers commented on Apr 25, 2019

    @fosskers
    ContributorAuthor

    Looks like when a symlink resolves to a directory, the getFiles call doesn't see it. Here are the keys of the files :: Map FilePath MetaEntry value in that function:

    ...
    "docs/en/pact-reference.md"
    "docs/en/pact-reference.rst"
    "docs/en/pacts.md"
    "docs/img/kadena-logo-100px.png"
    "docs/img/kadena-logo-210px.png"
    "docs/img/kadena-logo-trans.gif"
    "docs/ja/conf.py"
    "docs/ja/img"
    "docs/ja/index.rst"
    "docs/ja/pact-reference.md"
    ...
    

    Notice that it only has listings for the files inside the directory in question.

    The issue seems to be that symlinks are always counted as "files", even when the things they're pointing to are not.

  3. fosskers commented on Apr 25, 2019

    @fosskers
    ContributorAuthor

    Note also the call to normalizeParents, and the following in its documentation:

    -- * May not point to directories
    
  4. fosskers commented on Apr 25, 2019

    @fosskers
    ContributorAuthor

    For now I've hacked around the problem by just dumping anything that resulted in Left in toSimple. This is clearly incorrect, but unblocks me for the time being.

    I tried to think of a real solution, but being an outsider, I wasn't sure of the implications of say:

    • making foldArchive yield raw directory names as well
    • having toSimple live in IO so that I could do a doesDirectoryExist (it's unclear what dir we're even in, so how would testing the relative symlink make any sense?)
    • filtering out the results of getFiles ahead of time, to exclude any symlinks that point to directories

    Hopefully this is enough for a real stack dev to write the right solution 👍

  5. mihaimaruseac commented on Apr 26, 2019

    @mihaimaruseac
    Member

    Thanks for all this digging you've done.

  6. added this to the Stack 2 milestone on May 1, 2019
  7. snoyberg commented on May 1, 2019

    @snoyberg
    Contributor

    This is a good find, thank you! I'll need to look at the code again before coming up with any ideas.

  8. added a commit that references this issue on May 1, 2019
    a22adee
  9. snoyberg commented on May 1, 2019

    @snoyberg
    Contributor

    See #4793

  10. added a commit that references this issue on May 1, 2019
    91fc080
  11. fosskers commented on May 1, 2019

    @fosskers
    ContributorAuthor

    Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions