Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

‘fatal: Unable to read current directory: No error’ for every local Git repository I have #473

Closed
rexcfnghk opened this issue Oct 7, 2015 · 16 comments

Comments

@rexcfnghk
Copy link

Background

I currently have two git programs installed on my computer:

  • GitHub Desktop
  • Git For Windows

I use Git Bash most of the time and I use GitHub Desktop when I need a bigger picture of my repository.

Issue

The problem is I can no longer run any Git commands on Git Bash. This happens when I try to run git status:

rex@MyPC MINGW64 ~/My Documents/Source/FooRepository
$ git status
fatal: Unable to read current working directory: No error

The strange thing is it works perfectly fine in the Git shell that comes with GitHub desktop (which I believe is PowerShell based):

C:\Users\rex\My Documents\Source\FooRepository [master]> git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean
@rexcfnghk rexcfnghk changed the title 'fatal: Unable to read current directory: No error' for every local Git repository I have ‘fatal: Unable to read current directory: No error’ for every local Git repository I have Oct 7, 2015
@Radrik5
Copy link

Radrik5 commented Oct 7, 2015

Could you try a Git repo that doesn't have spaces in the path?

@dscho
Copy link
Member

dscho commented Oct 7, 2015

@rexcfnghk I will need substantially more information than that, and preferably a Minimal, Complete & Verifiable Example. Please study https://github.com/git-for-windows/git/wiki/Issue-reporting-guidelines and then provide the missing information.

@rexcfnghk
Copy link
Author

I am using the following environment:

  • Windows 7 64-bit
  • Git For Windows 64-bit v2.6.1
    • All commands are run inside Git Bash

When I try to git clone a remote repository into a directory with spaces in the path, it fails as shown in the follwing output (note there is a space in the file path):

rex@MyPC MINGW64 ~/My Documents/Source
$ git clone http://www.abcd.com/FooRepository.git
fatal: Could not get current working directory: No such file or directory

The other example is shown above when running git status in an existing repository, also with spaces in the file path.

When I try cloning into another directory without spaces in the file path, it clones successfully:

rex@MyPC MINGW64 ~/Source
$ git clone http://www.abcd.com/FooRepository.git
Cloning into 'FooRepository'
...

@rexcfnghk
Copy link
Author

Sorry it seems that I accidentally created the symlink My Documents that was creating this issue. Reverting to ~/Documents seems to solve the issue (even with spaces). Closing the issue.

@dscho
Copy link
Member

dscho commented Oct 8, 2015

Hmpf. That is really too scarce information, causing quite a bit of lost time on my end.

This is what I tried:

  1. I created a symbolic link to an existing directory via mklink /d symbolic-link existing-directory in an elevated cmd in my home directory.
  2. I started Git Bash and called cd symbolic-link
  3. Then I cloned a local repository via git clone ../existing-repository

This worked.

Then I tried the same with a junction point: mklink /j junction-point existing-directory as step 1., the other steps as above. And the same result: It worked.

So I guess that we will really not be able to fix this issue, unless you, @rexcfnghk, put in a little bit of an effort to come up with a Minimal, Complete & Verifiable Example.

@giacomocerquone
Copy link

I've the exact same problem and the only way I figured it out to get it to work is to give a cd to a repo with the full documents path (C:\Users\username\Documents\Gitrepo).
This happened to me, as you can see from the other post, when I updated Github and, more important, with the new windows 10 major update.

In fact now if I start a new powershell session and I go to the document folder without padding him the full path (just cd documents) it doesn't work!
So could be some new configuration in powershell I think!

UPDATE:
It actually seems to be a problem with symlink created from the translation of windows... if I give cd documenti (italian) it won't work, if I give cd documents it will work...

@dscho
Copy link
Member

dscho commented Dec 7, 2015

@giacomocerquone I get the distinct impression that there is a ton of really vital information that has been left out. You report that you have the exact same problem, but fail to mention which version and particular settings you use. Then PowerShell is mentioned briefly. How did you set Git up to be used from PowerShell? And then there is talk about a symlink in an update of the comment?

Seriously, it is a bit much to ask me to cobble back together a clear picture from these scattered bits and pieces. Please do not make my life so hard. You can do better than that.

@giacomocerquone
Copy link

Hi @dscho, I thought some of you would have opened the other issue, when I ask for help I'm always very specific. As I said:

Hi, I'm working in windows 10. I updated github for windows right yesterday (actual version 3.0.9.0, don't know if it means something) and git --version returns git version 2.5.3.windows.1
Now my problem is that every command I try to execute with git it returns: git unable to read current working directory no error (obviously the working directory isn't absolutely empty, and I also tried to create a new directory and initialize a new repo wit git init but it returns always the same error).

To use git I edited the profile.ps1 of powershell in this way:
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
. $env:github_posh_git\profile.example.ps1

@dscho
Copy link
Member

dscho commented Dec 7, 2015

This is a precise report: I downloaded Git for Windows 2.6.3 (64-bit), installed it with the "Windows default terminal" option, then I cloned a repository into my home directory and XYZ happened (I expected ABC instead). If I clone the same repository into C:\blub, it works.

With such a precise report, I would have a chance to reproduce your issue.

@giacomocerquone
Copy link

I don't know if you're doing just an example or you really didn't understand what I said. Anyway this seems hilarious to me, you're again seeking clarification from me but everything has been already written (just in an inconvenient order).
Let's organize it so:

I downloaded Github Desktop and installed it (it's an exe file) 8 months ago and for 4 months I always used the GUI version (never touched powershell or git directly). So 4 months ago I started using git from powershell (without installing anything) I just did what's written in this guide (basically it links posh-git used by Github Desktop that was already installed to the PATH environment variable editing the powershell profile).

I have always had my repos inside this folder: C:\Users\username\Documenti\Github\ ("Documenti" is the italian version of "Documents"... just to be precise).

When everything was working

Until a few days ago I've always worked with git giving this commands (and never a problem):

C:\Users\username>cd documenti\github\name-of-the-repo
C:\Users\Giacomo\documenti\github\name-of-the-repo> git status
On branch master
Your branch is up-to-date with 'origin/maste
nothing to commit, working directory clean

After windows 10 and github desktop update this doesn't work

But since I installed both the new Windows 10 major update and the new Github Desktop version this is what happened:

C:\Users\username>cd documenti\github\name-of-the-repo
C:\Users\Giacomo\documenti\github\name-of-the-repo [(master)]> git status
fatal: Unable to read current working directory: No error

After windows 10 and github desktop update this works (note the "documents" is that that make it works):

C:\Users\username>cd documents\github\name-of-the-repo
C:\Users\Giacomo\documents\github\name-of-the-repo [master]> git status
On branch master
Your branch is up-to-date with 'origin/maste
nothing to commit, working directory clean

These are the actual version of the software in question

Git

git --version
git version 2.5.3.windows.1

Github Desktop

Never Gonna Git You Up (3.0.9.0) dd3b7aa

Windows

Windows 10 Pro Threshold 2 version 1511

Conclusion

You said you're "getting the distinct impression..." and you were right, it's just an impression, we already said everything we could. I think that everyone here, included me, doesn't know which way to turn. Man I hope it is enough now, if it isn't I don't know what else I can tell you.

@dscho
Copy link
Member

dscho commented Dec 7, 2015

@giacomocerquone you do realize that

  1. this is the Git for Windows project, not the GitHub for Windows one?
  2. being testy makes it less likely that I even want to help you?

@giacomocerquone
Copy link

dahlbyk linked the issue I opened on posh-git here and so here we are and anyway doesn't matter that this is git for Windows because:

  1. we have the same problem apparently
  2. it's most likely an OS problem that we're trying to solve. Windows damaged some symbolic link during the update I think.

I don't want to be testy, but you're asking questions that more and more people already answered, but if you felt offended, I ask you sorry.

@happycollision
Copy link

Incidentally, for those who run into this problem in the future, the cause of the problem on my end was an intermediate folder permissions issue. For example, if the path is C:\folderA\folderB\myGitRepo, and there is a permission change to folderA or folderB, that might cause the problem. In my case, I needed to remove and then re-add my user to folderB. FYI.

@dscho
Copy link
Member

dscho commented Feb 21, 2017

@happycollision thank you for reporting this, and congratulations for the successful investigation!

@awatasoftsys
Copy link

/var/www/html/ERP$ git branch
fatal: Unable to read current working directory: No such file or directory

why this problem occuring

@dscho
Copy link
Member

dscho commented Mar 16, 2017

@awatasoftsys as you can see from the error message, this is a different problem than the one described in this ticket. In any case, it would make a lot of sense to try to come up with an MCVE and then to open a separate ticket.

dscho pushed a commit to dscho/git that referenced this issue Jan 15, 2022
…bug with deep sparse-checkout paths

We got multiple similar reports of failures with the sparse index (git-for-windows#473 as an issue, and another regarding `git checkout` via email). Both were hitting a similar set of paths, which was a hint.

The reason we didn't hit this before is because it requires the following:

1. The sparse-checkout definition needs to have recursive inclusion of deep folders (depth 3 or more).
2. _Adjacent_ to those deep folders, we need a deep sparse directory entry that receives changes.
3. In this particular repo, deep directories are only added to the sparse-checkout in rare occasions and those adjacent folders are rarely updated. They happened to update this week and hit our sparse index dogfooders in surprising ways.

The first commit adds a test that fails without the fix. It requires modifying our test data to make adjacent, deep sparse directory entries possible. It's a rather simple test after we have that data change.

The second commit includes the actual fix. It's really just an error of not understanding the difference between the `name` and `traverse_path` members of the `struct traverse_info` structure. `name` only stores a single tree entry while `traverse_path` actually includes the full name from root. The method we are editing also has an additional `struct name_entry` that fills in the tree entry on top of the `traverse_path`, which explains how this worked to depth two, but not depth three.

Resolves git-for-windows#473 
See also gitgitgadget#1092
dscho pushed a commit to dscho/git that referenced this issue Jan 20, 2022
…bug with deep sparse-checkout paths

We got multiple similar reports of failures with the sparse index (git-for-windows#473 as an issue, and another regarding `git checkout` via email). Both were hitting a similar set of paths, which was a hint.

The reason we didn't hit this before is because it requires the following:

1. The sparse-checkout definition needs to have recursive inclusion of deep folders (depth 3 or more).
2. _Adjacent_ to those deep folders, we need a deep sparse directory entry that receives changes.
3. In this particular repo, deep directories are only added to the sparse-checkout in rare occasions and those adjacent folders are rarely updated. They happened to update this week and hit our sparse index dogfooders in surprising ways.

The first commit adds a test that fails without the fix. It requires modifying our test data to make adjacent, deep sparse directory entries possible. It's a rather simple test after we have that data change.

The second commit includes the actual fix. It's really just an error of not understanding the difference between the `name` and `traverse_path` members of the `struct traverse_info` structure. `name` only stores a single tree entry while `traverse_path` actually includes the full name from root. The method we are editing also has an additional `struct name_entry` that fills in the tree entry on top of the `traverse_path`, which explains how this worked to depth two, but not depth three.

Resolves git-for-windows#473 
See also gitgitgadget#1092
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants