Coder Perfect

sh: 0: getcwd() failed: No such file or directory on cited drive

Problem

On Ubuntu 12.04, I’m attempting to compile ARM code (Precise Pangolin).

When I put the code in the local directory, everything works properly.

However, when I paste the code into the cited mount directory, I get the following error:

making testXmlFiles
sh: 0: getcwd() failed: No such file or directory
ARM Compiling xxxxx.c
sh: 0: getcwd() failed: No such file or directory

Here’s what I’ve got in fstab:

//10.0.0.1/data /mnt/data   cifs    auto,noserverino,credentials=/root/.smbcredentials,file_mode=0777,dir_mode=0777,uid=user,gid=users,noperm 0 0

So, what exactly is going on here? What could be the source of this error?

Asked by CrazyKitty Rotoshi

Solution #1

Running a command from a directory that no longer exists is the most common source of this error.

Change your directory and try running the command again.

Answered by Human

Solution #2

On a newly established directory, the same thing happened to me. The directory remains the same, however to get it to work again, simply type:

cd .

Answered by Roberto Rodriguez

Solution #3

Give the following command a shot. It was effective for me.

cd; cd -

Answered by timxor

Solution #4

This is something that can happen with symbolic links on occasion. If you’re having trouble with this and know you’re in an existing directory, but your symbolic link has changed, try the following command:

cd $(pwd)

Answered by smcjones

Solution #5

The following command works for me in Ubuntu 16.04.3 LTS (Xenial Xerus):

exit

Then I logged on again.

Answered by Is Ma

Post is based on https://stackoverflow.com/questions/12758125/sh-0-getcwd-failed-no-such-file-or-directory-on-cited-drive