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

I am trying to compile ARM code on Ubuntu 12.04 (Precise Pangolin).
Everything is working fine when I put the code in the local directory.
But when I put the code in the cited mount directory, an error shows up:
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 is my setting 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
What is going on here? What could cause this error?

This error is usually caused by running a command from a directory that no longer exists.
Try changing your directory and rerun the command.

That also happened to me on a recreated directory. The directory is the same, but to make it work again, just run:
cd .

Try the following command. It worked for me.
cd; cd -

This can happen with symbolic links sometimes. If you experience this issue and you know you are in an existing directory, but your symbolic link may have changed, you can use this command:
cd $(pwd)

In Ubuntu 16.04.3 LTS (Xenial Xerus), the following command works for me:
exit
Then I've login again.

Please check whether the directory path exists or not. This error comes up if the folder doesn't exist from where you are running the command.
Probably you have executed a remove command from the same path on the command line.

If some directory/folder does not exist, but somehow you navigated to that directory, in that case you can see this error.
For example:
currently, you are in the "mno" directory (path = abc/def/ghi/jkl/mno
run "sudo su" and delete mno
go to the "ghi" directory and delete the "jkl" directory
now you are in the "ghi" directory (path abc/def/ghi)
run "exit"
after running the "exit", you will get that error
now you will be in "mno"(path = abc/def/ghi/jkl/mno) folder. That does not exist.
So, generally this error will show when the directory doesn't exist.
To fix this, simply run "cd;" or you can move to any other directory which exists.

In my case, none of the previous answers has worked.
After banging my head against the wall for a while I've found out, that I've destroyed the /etc/passwd entries by running a custom-made-linux-server-setup-bash-script which worked well previously, but this time the regex within the "sed" command erased all the existing entries :D
After copy pasting the default entries from another working Linux server, I could finally restart sshd.
So don't forget to back up the original /etc/passwd file before applying any regular expression replacements on it :)

Related

Bash: app definitely on $path, but not found when run

I'm having a issue with a python app that I installed on a empty server.
The package I installed is invoke using pip3 install invoke
After install if I just run invoke without specifying the abs path, then I
get a error: -bash: /usr/bin/invoke: No such file or directory
Running it with the full path to the app works fine.
So I'm confused why it's ignoring the legit app that is in a location
that is definitely on the $PATH.
See the cli commands below for visual reference:
/# invoke
-bash: /usr/bin/invoke: No such file or directory
/# find -name invoke
./usr/local/bin/invoke
./usr/local/lib/python3.6/dist-packages/invoke
/# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/# /usr/local/bin/invoke -V
Invoke 1.4.1
Anyone know what's going on here?
As mentioned in the comments of my original post, this was because the command was previously hashed and bash remembered the old path. Running hash -r was suggested, which resets all mappings. I eventually used hash -d invoke which cleared only that single entry. My reasoning was that I wasn't sure if anything else in the mappings were expected to be there by some other app.
Edit: As pointed out in the comments below, there is no harm in using -r since it's just a faster way to look something up and is saved there once it finds it again anyway.

How do I run man without using sudo and not under root directory?

I've encountered a problem that I can't seem to find a solution for. Running the man command anywhere that isn't in ~ or without using sudo returns:
"/usr/bin/man: can't execute less: Invalid argument
/usr/bin/man: command exited with status 255: ..."
I've tried running export MANPAGER=less
$PAGER and $MANPAGER are set to less. It still does not seem to work.
What do I do?
Edit:
After further review I've noticed that the command works everywhere except a mounted network directory that I use. I can use less and echoman ls`` just fine, but just using man as usual brings up the mentioned issue.
Try to change the permission and ownership of /usr/bin/man. Make it so that it is executable by everyone.

Why does make.exe try to run /usr/bin/sh on Windows?

I have recently moved from Window 7 to Windows 10 and I cannot get my makefiles to work anymore.
I have been using the GNU Make for Windows
The first thing that I noticed was that it had started treating Windows folder dividers (backslash characters '\') as line continuation characters, so I modified the 'clean' section as shown below to use forward slash '/' characters instead:
clean:
del $(ObjDir)/*.o
When I call make -ftest.mak clean I get the following error which suggests it is now trying to run in a MinGw/Cygwin environment:
c:\Test\Source>make -ftest.mak clean
del obj/*.o
/usr/bin/sh: del: command not found
make: *** [clean] Error 127
I do have MinGw folder on my PC (which I have renamed to stop make looking for it) and I can't see any 'MingGw' related environment variables in my Cmd.exe environment or PATH
How can I get make working so it doesn't try executing sh under Windows?
Is there some configuration parameter somewhere that makes it call sh instead of cmd.exe?
Update: Just tried running make -d which logs debug output. It looks as though it is using my Git folder as some sort of root folder:
Must remake target `clean'.
del obj/*.o
CreateProcess(NULL,C:/Program Files/Git/usr/bin/sh.exe -c "del obj/*.o",...)
Putting child 0x006e7fc0 (clean) PID 7234712 on the chain.
The cleanest way is to specify SHELL on command line.
make -ftest.mak clean SHELL=cmd
will do the job. ndk-build will do that for you, see your ndk-build.cmd. Don't try to run ndk-build bash script on Windows. The scripts in NDK may go amoc when you run them on Windows in bash.
Nasty conclusion to this problem.
make looks through the PATH environment variable for anything containing usr/bin. It just so happens that since I also installed Git on my Windows 10 PC, Git added the following folder to PATH:
C:\Program Files\Git\usr\bin
Adding any path with the substring "usr\bin" will cause make to try running sh instead of cmd.exe on Windows.
My solution: Remove the C:\Program Files\Git\usr\bin from my PATH.
Update: I changed the name from usr\bin to user\bin but make still finds sh.exe within that folder. In the end I renamed sh.exe to _sh.exe within the Git\usr\bin folder.

Having trouble creating path to executable program in linux

I've been having a lot of trouble trying to set up a path to an executable file in linux. Sorry If it's a dumb question, but I'm new to linux and still figuring things out.
Anyways, the file I want to create a path to is located at:
/opt/gitools/gitools-2.3.1/gitools
So I created a path at the end of my .bashrc file:
export PATH=$PATH:/opt/gitools/gitools-2.3.1/
I've checked, and the file gitools as well as all parent directories are marked as executable. However, when I enter "gitools", it returns:
/bin/bash: /opt/gitools/gitools-2.3.1/gitools: Permission denied
And when I enter "sudo gitools", it returns:
sudo: gitools: command not found
There is nothing wrong with the program itself, because I can run it by going to its directory and entering "sudo ./gitools", however, I'm unsure of why I need sudo when it should be executable for all users.
Any help is greatly appreciated!
I finally figured out a solution that works.
I tried to give full read write execute permission to all files in the program, but that just created errors that prevented running the program at all.
However, I noticed that the owner of all of the files was set to root, so in a last ditch attempt to get it to work I decided to recursively change the ownership of all directories and files associated with the program by going to the /opt directory and entering:
sudo chown -R myUsername:myUsername gitools/
Hope that this might help someone with a similar problem!

Node.Js windows command prompt change C:\ path to test directory instead

I'm trying to figure out if there is a way to change the Node.Js command prompt default path = C:\users...> (default when the prompt is launched) or C:\Windows\System (if launched with administrator privileges), to the location of the folder where i'm working.
Normally I have been doing C:\users..> cd C:\xampp\htdocs..... to navigate to the test folder and run test. Although once the command prompt is closed it reverts back to C:\users...>.
To achieve what I want I came across using Z:>C:\xampp\htdocs\projects.... but this returns access denied with or without administrator privileges. Even if I try C:>C:\xampp\htdocs\projects.... still get the Access Denied for some unknown reason. To be honest I don't know what Z:> or C:> will result.
Is it possible to change the default prompt path to the path of the directory I am working in so that every time command prompt is launched it goes to that directory? In this case C:\xampp\htdocs\projects.... instead of C:\users...>
This seems like a general windows CMD question. Simply change the start up directory for CMD. See this SO post.
Once you're in that directory, you should be able to run the node command as normal.
Look inside your default nodejs installation folder for a file called nodevars.bat. Here is my path:
C:\Program Files\nodejs\nodevars.bat
Open this and look towards the bottom--the line I needed was on the very bottom. Here is the line from the git master:
if "%CD%\"=="%~dp0" cd /d "%HOMEDRIVE%%HOMEPATH%"
I changed mine to
if "%CD%\"=="%~dp0" cd /d "C:\Users\David\Desktop\work\J\math"
And now I am happier.
I had the same question, today, 4/11/22, and DuckDuckGo provided this as the number one result for my query. Since the question appears to be unanswered, I will try for those who might show up later.

Resources