12

I am trying to compile ARM code in Ubuntu 12.04.

Everything is working fine when I put my code in local directory. But when I put the code in cited mount directory this error happens:

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

Here is my mount command:

sudo mount -t cifs -o username=wx,passwd=wx,auto,nounix,noserverino,file_mode=0777,dir_mode=0777,uid=user,gid=users,noperm,rw,uid=1002,gid=1002 //192.165.54.18/prj_9330  /home/dongjw/work_dir/work_9330

I am using Ubuntu 12.04 64bit

What would cause this error?

7

I got this error using jshint through a python subprocess on Ubuntu 12.10 64 bit.

node.js:464
var cwd = process.cwd();
                  ^
Error: ENOENT, no such file or directory
    at Function.resolveArgv0 (node.js:464:23)
    at startup (node.js:51:13)
    at node.js:555:3

It is caused because you deleted or moved a directory out from underneath it and the current directory can't be determined.

How to tell if you are having this problem:

Run the command cd . (If you get this error then you have this problem).

el@apollo:~/foo$ cd .
cd: error retrieving current directory: getcwd: cannot access parent 
directories: No such file or director

You tried to change directory into your current dir, and could not.

How to reproduce the error:

jshint is affected by this error. Make a directory foo, cd into it, make a file called myjavascript.js

cd /home/el
mkdir foo
cd foo
touch myjavascript.js
jshint myjavascript.js

jshint runs correctly, it says there are no errors which is correct.

Open a 2nd terminal, and rm -rf the directory /home/el/foo out from underneath.

rm -rf /home/el/foo

Run the jshint myjavascript.js again from your first terminal and you get an error:

el@apollo:~/foo$ jshint myjavascript.js 

    node.js:464
        var cwd = process.cwd();
                      ^
    Error: ENOENT, no such file or directory
        at Function.resolveArgv0 (node.js:464:23)
        at startup (node.js:51:13)
        at node.js:555:3

The directory is gone! And even if you were to replace it with the same contents, it has a different signature and the terminal can't recover, the method getcwd can't know what the current directory is.

Three Solutions:

The terminal is confused about what the current directory is because its gone or it's signature has changed. Do one of these to fix it:

  1. Run the command cd .. until you stop getting errors. This re synchronizes the terminal with the filesystem. Then cd back into your directory. Try again. The error goes away.

  2. Use su youruser in the terminal, enter the password. It refreshes and brings you back to the same directory.

  3. Close and reopen the terminal which flushes away the stale directory signatures. Or send a nastymail to whatever program (jshint) or the thousands of other programs which can't tolerate or recover from stale directory signatures.

| improve this answer | |
  • instead of running cd .. "often enough" you could also just cd ~ directly to your homefolder – derHugo Jun 14 '18 at 13:33
4

I get the same error, but I was trying to run a script in my home directory. I solved it with:

pushd ~ 1>/dev/null; pwd ; popd 1>/dev/null

This moves my to my home directory, then runs pwd (but you can run anything that you like) and then the popd moves me back to where I was. If you don't need to move back then

cd; pwd

Would be enough to solve my problem, (I hope that it helps with yours.)

edit The 1>/dev/null parts are optional; I add them so that I can use the above line within a shell script without additional output that isn't needed in this case.

| improve this answer | |
  • So that I can past this into a bash script and not end up with output that I don't want. I try to add as complete an answer as I can because when I find commandline-fu I find it easy to cut it down to my needs and I expect anyone that is using this to be a bit like me. – Alexx Roche Sep 6 '13 at 6:20
  • ok, I've added an edit explaining, (though some might feel that I'm teaching them to suck eggs - those that know do not need the edit and those that do not know can cut-n-paste, or look up that function that is not directly related to the original question.) – Alexx Roche Sep 7 '13 at 8:17
  • Sadly is like that :( – Braiam Sep 7 '13 at 10:52
-1

Even i was having the same problem with python virtualenv. It got corrected by a simple restart

sudo shutdown -r now
| improve this answer | |
  • 2
    I wouldn't think you would need to restart to fix it, just follow the other answers here, and cd to an existing directory. – wjandrea May 8 '18 at 18:21
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – N0rbert May 8 '18 at 21:49
  • 1
    @N0rbert This is not a new question, it's clearly an attempt to answer and providing an IMHO valid (although surely not optimal) solution. – Byte Commander May 8 '18 at 21:55
  • @ByteCommander I clicked this by mistake, I'm sorry. – N0rbert May 9 '18 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.