threads / discuss / 15608

clone fails: Could not get the current working directory

Subject: clone fails: Could not get the current working directory

## tl;dr

12 messages between Sep 21, 2008 and Sep 24, 2008.

replies: 11people: 2as markdown or json

John Freeman· Sep 21, 2008, 00:49 UTC · lore
Howdy,
I'm trying to clone a remote repository.  Here's the background:
- The repository is bare, under Bob's home directory on a remote Sun system.
- Bob has set the group permissions for the repo directory to repogroup.
- I have an account on the remote system that is in repogroup.
I am trying to clone the repo on my home machine, using
 > git clone ssh://john@remote.system.edu/home/bob/path/to/repo
It fails with

remote: fatal: Could not get the current working directory error: git-upload-pack: git-pack-objects died with error. fatal: git-upload-pack: aborting due to possible repository corruption on the remote side. remote: aborting due to possible repository corruption on the remote side. fatal: early EOF fatal: index-pack failed

Checking the source code, this error is triggered after getcwd() returns a null pointer in setup.c:set_work_tree(), which is called at only one place, in setup.c:setup_git_directory_gently().

Can anyone provide any insight as to why am I seeing this error?

Thank you, John

Alex Riesen· Sep 23, 2008, 12:39 UTC · re: John Freeman · lore

Re: clone fails: Could not get the current working directory

2008/9/21 John Freeman <jfreeman@cs.tamu.edu>:
Show 11 quoted lines
> - The repository is bare, under Bob's home directory on a remote Sun system.
> - Bob has set the group permissions for the repo directory to repogroup.
> - I have an account on the remote system that is in repogroup.
>
> I am trying to clone the repo on my home machine, using
>
>> git clone ssh://john@remote.system.edu/home/bob/path/to/repo
>
> It fails with
>
> remote: fatal: Could not get the current working directory
Do these work:
  $ ssh john@remote.system.edu ls -R /home/bob/path/to/repo
  $ ssh john@remote.system.edu 'cd /home/bob/path/to/repo && pwd'
?
John Freeman· Sep 23, 2008, 13:23 UTC · re: Alex Riesen · lore

Re: clone fails: Could not get the current working directory

Alex Riesen wrote:
> Do these work:
>   $ ssh john@remote.system.edu ls -R /home/bob/path/to/repo
>   $ ssh john@remote.system.edu 'cd /home/bob/path/to/repo && pwd'
>   

Yes, they do. I wish the mailing list did better threading; please see my other posts if you happened to miss them:

http://article.gmane.org/gmane.comp.version-control.git/96442 http://article.gmane.org/gmane.comp.version-control.git/96505

Thank you, John

Alex Riesen· Sep 23, 2008, 14:12 UTC · re: John Freeman · lore

Re: clone fails: Could not get the current working directory

2008/9/23 John Freeman <jfreeman@cs.tamu.edu>:
Show 13 quoted lines
> Alex Riesen wrote:
>>
>> Do these work:
>>  $ ssh john@remote.system.edu ls -R /home/bob/path/to/repo
>>  $ ssh john@remote.system.edu 'cd /home/bob/path/to/repo && pwd'
>>
>
> Yes, they do.  I wish the mailing list did better threading; please see my
> other posts if you happened to miss them:
>
> http://article.gmane.org/gmane.comp.version-control.git/96442
> http://article.gmane.org/gmane.comp.version-control.git/96505
>

Saw them. .bashrc (/etc/bashrc too) is not used for non-interactive sessions, like yours (of course, you can source them from .profile/.bash_login/.bash_profile).

Have you tried the commands exactly? (Even more interesting would be to try a simple getpwd program which prints errno)

John Freeman· Sep 23, 2008, 14:45 UTC · re: Alex Riesen · lore

Re: clone fails: Could not get the current working directory

Alex Riesen wrote:
Show 8 quoted lines
> Saw them. .bashrc (/etc/bashrc too) is not used for non-interactive 
> sessions,
> like yours (of course, you can source them from
> .profile/.bash_login/.bash_profile).
>
> Have you tried the commands exactly? (Even more interesting would be to try
> a simple getpwd program which prints errno)
>   

I have. I'm convinced that the problem is not missing commands; if it were, I'd be getting a "missing command," or "file not found," or similar error. Like I've said, I am able to get this to work when the repo is in my home directory. It only fails when the repo is on another path in the system for which I do not have read privileges all the way down - only at the end.

- John
Alex Riesen· Sep 23, 2008, 15:01 UTC · re: John Freeman · lore

Re: clone fails: Could not get the current working directory

2008/9/23 John Freeman <jfreeman@cs.tamu.edu>:
Show 14 quoted lines
> Alex Riesen wrote:
>>
>> Saw them. .bashrc (/etc/bashrc too) is not used for non-interactive
>> sessions,
>> like yours (of course, you can source them from
>> .profile/.bash_login/.bash_profile).
>>
>> Have you tried the commands exactly? (Even more interesting would be to
>> try
>> a simple getpwd program which prints errno)
>>
>
> I have.  I'm convinced that the problem is not missing commands; if it were,
> I'd be getting a "missing command," or "file not found," or similar error.

I actually expected "ls -R" giving error about unable to read the directory (permissions).

>  Like I've said, I am able to get this to work when the repo is in my home
> directory.  It only fails when the repo is on another path in the system for
> which I do not have read privileges all the way down - only at the end.
Again: try a simple program which just does getpwd for this pathname
John Freeman· Sep 23, 2008, 21:16 UTC · re: Alex Riesen · lore

Re: clone fails: Could not get the current working directory

Alex Riesen wrote:
> I actually expected "ls -R" giving error about unable to read the 
> directory (permissions).
This worked.
> Again: try a simple program which just does getpwd for this pathname
 From what I gather, getpwd() is in libiberty, which I didn't feel like 
messing with for this example.  I ran a small test program that called 
getcwd() in the repo directory, and it failed.  errno was set to EACCES, 
indicating insufficient permissions.
http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html

I may get around later to patching this, but for now we're moving ahead with a workaround.

- John
Alex Riesen· Sep 24, 2008, 11:30 UTC · re: John Freeman · lore

Re: clone fails: Could not get the current working directory

2008/9/23 John Freeman <jfreeman@cs.tamu.edu>:
Show 7 quoted lines
> Alex Riesen wrote:
>> Again: try a simple program which just does getpwd for this pathname
>
> From what I gather, getpwd() is in libiberty, which I didn't feel like
> messing with for this example.  I ran a small test program that called
> getcwd() in the repo directory, and it failed.  errno was set to EACCES,
> indicating insufficient permissions.
So there we are...
> http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html
It suggest a rather dubious workaround (calling pwd).
> I may get around later to patching this, but for now we're moving ahead with
> a workaround.

...but that's a system-inflicted workaround. We just have to do it or something like what it does.

General question: What does Sun's pwd do?
John Freeman· Sep 24, 2008, 13:30 UTC · re: Alex Riesen · lore

Re: clone fails: Could not get the current working directory

Alex Riesen wrote:
> General question: What does Sun's pwd do?
>   

It works like you'd expect. There are no permission problems. Even in directories for which I don't have read access, it will show the path.

- John
Alex Riesen· Sep 24, 2008, 14:43 UTC · re: John Freeman · lore

Re: clone fails: Could not get the current working directory

2008/9/24 John Freeman <jfreeman@cs.tamu.edu>:
Show 6 quoted lines
> Alex Riesen wrote:
>>
>> General question: What does Sun's pwd do?
>
> It works like you'd expect.  There are no permission problems.  Even in
> directories for which I don't have read access, it will show the path.

No, not what it shows. What does it call? Which syscalls it uses so we can use them also. Or is /bin/pwd root-SUID?

John Freeman· Sep 21, 2008, 22:18 UTC · lore

Re: clone fails: Could not get the current working directory

Paul Johnston wrote:
> On the server, where is git installed? I had a similar problem with
> clone when my git installation was not in a PATH known to ssh. 

It is installed in a non-standard directory, /opt/csg/bin. This is part of the system-wide PATH defined in /etc/bashrc. I also added it to my ~/.bashrc before I discovered that fact.

> Try
> creating symlinks from usr/bin (for example) to your git executables
> to see if this solves the problem.

I did create symlinks in $HOME/local/bin which is in the PATH defined in my ~/.bashrc. I do not have administrator privileges, so I cannot put symlinks in /usr/bin. I think it is finding the executable just fine, but that there is some issue with accessing the repo directory. I have tested with

 > ssh user@remote.system.edu -- "git-upload-pack"
and it works as expected.
>   Also, search the archives for
> git-upload-pack.
>   

I've skimmed it, and I see nothing related to my problem. Specifying --upload-pack explicitly gives the same error.

Thank you for the response, though.  Are there any other ideas?
- John
John Freeman· Sep 22, 2008, 18:32 UTC · re: John Freeman · lore

Re: clone fails: Could not get the current working directory

I have also tried copying the repo to my home directory on the remote Sun machine, and then cloning to my local machine. This works as expected.

Does anyone know why a call to getcwd() would fail?

I found this in some documentation on getcwd: http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html "If a program is operating in a directory where some (grand)parent directory does not permit reading, getcwd() may fail, as in most implementations it must read the directory to determine the name of the file. This can occur if search, but not read, permission is granted in an intermediate directory, or if the program is placed in that directory by some more privileged process (for example, login). Including the [EACCES] error condition makes the reporting of the error consistent and warns the application writer that getcwd() can fail for reasons beyond the control of the application writer or user. Some implementations can avoid this occurrence (for example, by implementing getcwd() using pwd, where pwd is a set-user-root process), thus the error was made optional."

Does anyone know for certain if this is true for Sun machines? Would it be possible to patch / introduce a macro that changes the use of getcwd() to a use of pwd, like the above documentation suggests?

- John

← back to recent threads