Skip to content

Symbolic link exists, but is pointing to the wrong location #1188

Description

@cowwoc

Version 1.15.1

If the same workspace is mounted from different locations (e.g. two different docker images that share a host-based code repositoy but mount it at different paths) then:

  1. pnpmExecutable.exists() returns false, because although the symbolic link already exists it points at a non-existent location (the location resolves in the other Docker container, not the current one)
  2. !pnpmJsExecutable.exists() returns false, because the file we are trying to link to does exist.
  3. Files.createSymbolicLink(pnpmExecutable.toPath(), pnpmJsExecutable.toPath()); gets invoked but throws java.nio.file.FileAlreadyExistsException because the symbolic link already exists.

This is a combination of user error (the repository should be bound to a consitent path across containers) and a bug (the code assumes that the symbolic link does not exist when it does).

Suggested fix: If the symbolic link exists but is pointing at a non-existant path, delete and then replace it. Yes, the symbolic link will keep on getting recreated as users shift from one docker container to another but this is mostly harmless (fast) and the build will pass.

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