Skip to content

Cannot cd out of directory using tilda for home (~) #3143

Closed

Description

@MozarellaMan

Describe the bug
When I try to cd out of my directory to a directory from HOME using the tilda (~) symbol, for example cd ~\Documents\ , I get the error error: Cannot change to directory. To get around it I do cd ~ then cd Documents\ but this is quite annoying. Also when I do this starship starts displaying weird (not properly showing the current dir) but that might be something to do with starship.

To Reproduce
Steps to reproduce the behavior:

  1. cd to a directory
  2. Change our of that directory with tilda like cd ~\Documents\
  3. returns "error: Cannot change to directory"

Expected behavior
To change directory to ~\Documents\

Screenshots
image

Configuration (please complete the following information):

Run version | pivot and paste the output to show OS, features, etc.

> version | pivot
╭───┬────────────────────┬───────────────────────────────────────────────────────────────────────╮
│ # │ Column0            │ Column1                                                               │
├───┼────────────────────┼───────────────────────────────────────────────────────────────────────┤
│ 0 │ version            │ 0.27.1                                                                │
│ 1 │ build_os           │ windows-x86_64                                                          │
│ 2 │ rust_version       │ rustc 1.50.0                                                          │
│ 3 │ cargo_version      │ cargo 1.50.0                                                          │
│ 4 │ pkg_version        │ 0.27.1                                                                │
│ 5 │ build_time         │ 2021-03-07 22:01:06                                                   │
│ 6 │ build_rust_channel │ release                                                               │
│ 7 │ features           │ ctrlc, default, directories, dirs, git, ichwh, ptree, │
│   │                    │ rustyline, term, uuid, which, zip                                     │
╰───┴────────────────────┴───────────────────────────────────────────────────────────────────────╯

Add any other context about the problem here.

Activity

  1. sophiajt commented on Mar 8, 2021

    @sophiajt
    Contributor

    @MozarellaMan - does doing cd ~/Documents/ work? I'm wondering if it's a bug in how we expand the path on Windows

  2. MozarellaMan commented on Mar 8, 2021

    @MozarellaMan
    Author

    @MozarellaMan - does doing cd ~/Documents/ work? I'm wondering if it's a bug in how we expand the path on Windows

    Yes! That does work. Still that weird issue with the directory display on starship not updating till I enter another command to confirm. Again could be a starship issue, but this is the only situation I've seen it happen. Also, yeah, using forward slash breaks autocomplete for me ( #2535 )

  3. kubouch commented on Mar 8, 2021

    @kubouch
    Contributor

    There is a couple of cases of inconsistent path handling and weird issues like this one. I believe this particular issue comes from the dependency shellexpand which doesn't support tilde expansion on Windows paths. This is something I wanted to look at more closely with my next PR and hopefully fix these subtle errors.

  4. fdncred commented on Mar 27, 2021

    @fdncred
    Contributor

    I'm pretty sure I fixed this with #3210. Please re-open this if I did not.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions