Skip to content

use of ~ (home directory alias) does not resolve, and no warning message about it #5410

Open

Description

@catalandres

I have a local repository in a hidden folder and the "Add Local Repository" modal does not let me add it. The "Add Repository" button is greyed out.

image

Activity

  1. shiftkey commented on Aug 15, 2018

    @shiftkey
    Member

    @catalandres can you also include the OS and version of Desktop you are running, to help with reproducing the issue?

  2. added
    more-info-needed
    on Aug 15, 2018
  3. shiftkey commented on Aug 22, 2018

    @shiftkey
    Member

    @catalandres I tried to reproduce this and the issue is not with the .zprezto folder but with using ~/, which we don't resolve currently. I'll update the issue to reflect this, because we should make it clearer that we're not currently doing that.

  4. changed the title [-]Cannot add a local repository in a hidden (dot-prefixed) folder[/-] [+]use of ~ (home directory alias) does not resolve, and no warning message about it[/+] on Aug 22, 2018
  5. added
    bug
    macOS
    and removed
    more-info-needed
    on Aug 22, 2018
  6. added
    priority-3
    on Oct 11, 2018
  7. francisrath commented on Aug 4, 2026

    @francisrath
    Contributor

    Still reproduces in 3.6.3 on macOS 26.5.2. @shiftkey's 2018 diagnosis is still the right one, though the code has moved on a bit since: untildify is in this dialog now, it's just applied after the validation that rejects the path.

    addRepository validates the raw text first and only expands afterwards:

    const { path } = this.state
    const isValidPath = await this.validatePath(path)   // raw path, still contains ~
    
    if (!isValidPath) {
      this.pathTextBoxRef.current?.focus()
      return                                            // never gets any further
    }
    
    const resolvedPath = this.resolvedPath(path)        // untildify happens here
    const repositories = await dispatcher.addRepositories([resolvedPath])

    validatePath → getRepositoryType starts with a directoryExists check, and a literal ~/… doesn't exist as far as the filesystem is concerned, so the result is always missing and the early return means resolvedPath is never reached. Validating the resolved path instead would fix it — resolvedPath already handles the tilde and makes the path absolute.

    The symptom has changed since the original report, for anyone searching: the Add Repository button is no longer greyed out (there's no disabled on it any more), so it looks clickable. Clicking it just shows "This directory does not appear to be a Git repository" and offers to create one at a path that already has a repository.

    It's also worse than it first appears, because the warning doesn't clear when you correct the path (#22648) — so after a tilde path fails, switching to the absolute path leaves the warning on screen next to a path that's perfectly valid, which reads as though the repository itself is the problem.

    I opened #22651 for this before spotting this issue, and I've closed it in favour of this one.

    I'll put a PR up shortly. Could someone add help wanted here if you'd like it? Without it the PR trips the requirements check and gets marked unmet-requirements, which seems a shame for an eight-year-old bug with a one-line fix.

  8. francisrath commented on Oct 13, 2026

    @francisrath
    Contributor

    Could a maintainer add the help wanted label to this issue?

    I have a tested fix ready in #22652: the dialog validates the path before expanding ~, so it now validates the resolved path instead. It's a draft for now because I already have a PR open in this repo, and I'll take it out of draft as soon as that one merges. Verified in a development build: repositories under ~/… now add, plain folders under ~ are still rejected, and absolute paths behave as before.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmacOSpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions