Cygwin C:/Program: No such file or directory - cygwin

After migrating from Windows 7 to Windows 10, I re-installed Cygwin. When I run from Cygwin I'm getting following error:
/cygdrive/c/Cygwin64/bin/sh: C:/Program: No such file or directory
Any idea what this could be related to ?

This is the result of spaces in windows file or directory names.
To properly diagnose the problem, you will need to quote the exact command you enter, and the value of the cygwin PATH variable, e.g. echo $PATH.
Typically, this problem is fixed by quoting shell commands so the shell does not split path names on the spaces within file paths. You add double or single quotes around literal file paths, e.g. '/cygdrive/c/Program Files/...', and double quotes around variable references, e.g. "$FileName" in shell commands and scripts.
When you install or re-install cygwin, it is very important to not install to a directory with a space in its path name, do not use e.g. C:\Cygwin 64; instead use C:\Cygwin64 or C:\Cygwin_64. If you do install to such a path, your best bet is to delete that installation and reinstall to a path without a space in it.

Related

How to make command "Hadoop" work in linux 18.04?

I installed Hadoop and now it works with command /usr/local/hadoop/bin/hadoop.
Where and how should I add this path to make command hadoop work without a full path to file? I already tried .bashrc and /etc/environment, but it didn't help.
You need to add it to your PATH environment variable. PATH is used to find programs to run in the shell.
To see what your current PATH is you can type
$ echo $PATH
When you update the PATH variable you want to make sure you don't delete previous entries.
$ PATH=$PATH:/usr/local/hadoop/bin

Terminal Linux - referencing executable file - No such file or directory

I'm not great in the terminal, and I can't figure out why its returning this. It's probably really obvious so apologies for asking, but the executable file I'm referencing is definitely in that file path, and after researching I can't seem to find an answer:
/home/user/protoc-3.5.1-linux-x86_64/bin/protoc object_detection/protos /*.proto --python_out=.
object_detection/protos/*.proto: No such file or directory
(I can't cd into it as I need to do this in a particular directory)
Thanks
It seems bash is looking for a specific file that has the name "[star]" instead of using this as a wildcard.
I think you might need to use a pipe to get the desired result.
From your command line, it looks like protoc is the executable, located at /home/user/protoc-3.5.1-linux-x86_64/bin/protoc. And that you're giving it two arguments separated by a space: object_detection/protos and /*.proto. If you have spaces in the file path, you'll need to escape them or double-quote them:
protoc object_detection/protos\ /*.proto or
protoc "object_detection/protos /*.proto"
The odd thing is that the error message indicates differently:
object_detection/protos/*.proto: No such file or directory
Or possibly the protoc executable needs the absolute (complete) path for file arguments. If from your current working directory the command ls object_detection/protos/*.proto shows results for you, then you can try running your command like this to use absolute file paths:
/home/user/protoc-3.5.1-linux-x86_64/bin/protoc $PWD/object_detection/protos/*.proto
$PWD is an environment variable that contains your working directory path.

remove entries from PATH while uninstalling rpm

To leave the system in a cleaner state, I am trying to remove entries from the PATH in the %preun section of my rpm spec file.
I found couple of threads on stackoverflow that I tried
What is the most elegant way to remove a path from the $PATH variable in Bash?
AND
Linux: Remove path from $PATH variable
Answers in both these links work perfectly when I manually run them on a terminal.
But, they don't work when I run the rpm -e xx command.
If my PATH looked like this after successful installation:
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lpp/mmfs/bin
and I am trying to remove /usr/lpp/mmfs/bin,
After the rpm uninstall the PATH looks like:
/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
Questions:
1) Do I need to do something different when the commands mentioned in the earlier links are run from the spec file?
2) What are some recommended ways to remove PATH entries during rpm uninstalls?
Note
Commands I have tried in spec file are:
PATH=$(echo $PATH | sed -e 's;:\?/home/user/bin;;' -e 's;/home/user/bin:\?;;')
and
PATH=${PATH/:\/home\/user\/bin/}
The RPM %preun script cannot affect the PATH variable of any running shells. That isn't possible.
It can't (directly) affect the PATH variable of any new shells either.
The only thing it can do is remove whatever changes it made to the system (or user shudder) shell startup files that caused the PATH variable additions to be made.
Removing those changes will cause any new shells not to have those changes made and therefore not to have those additional PATH entries in them.
The proper way of adding to a PATH (and subsequently, removing it later), would be to drop a file yourpackage.sh and yourpackage.csh in /etc/profile.d.
I also agree with others that it's probably a bad idea, but if you need to do it, that's how I would.

How do I change the directory in Git Bash with Git for Windows?

How would I change to the directory C:/Users/myname/project name in Git Bash?
cd /c/users/myname/project\ name
Beware that ls /, or typing cd / followed by Tab-completion, might not show the existence of this folder, but cd /c will still work. Also note that pwd (to print the current working directory) might show something like /bin, but this might not be the actual working folder for commands such as git clone, which might use the folder from which Git Bash was started.
If the you know how many levels up from your current working directory, you could use cd ../project/name to avoid writing the entire directory path.
The .. represents moving 1 directory up.
You will need to use quotes in your directory name, or the short version of the filename.
You can find the short version of the file name by issuing the command:
dir /x
If I remember correctly. I do not have a windows machine.
It is a version of bash shell though, so you should be able to simply quote it. (And the dir /x may or may not work.)
If you are at the a directory and wanna switch to sub directory use :
cd "project name"
If you wanna go to a different path use the whole path :
cd "C:/Users/myname/project name"
But you can avoid use white spaces in project files and folders and instead use underscore
An alternative that worked for me (Windows 10 x64) is putting the full address in quotes:
cd "D:\BWayne\Documents\- School\Developer\-- Backend\Test for GitBash"
I could then do like mkdir, touch, etc and it successfully put them in the Test for GitBash folder.

export JAVA_HOME with spaces in Cygwin

I'm trying to set my JAVA_HOME in Cygwin with this command:
export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.7.0_10"
But when I do cd $JAVA_HOME, I'd get this error:
$ cd $JAVA_HOME
-bash: cd: /cygdrive/c/Program: No such file or directory
I tried quoting, and escaping the space (ie., \), but none worked.
Any idea what else would?
Thanks,
I faced this problem too and I saw many posts but nothing really worked. There is a small trick that I did and things started working.
My JAVA_HOME was set to C:/Program Files/Java/jdk1.7.0_23.
The problem was with Program Files directory and I was getting the same error.
In Windows there is a short name created for every directory with a space which is without a space.
You can see it by running dir /X command on the command prompt.
The Short name for Program Files was PROGRA~1.
In the Windows env variable through My Computer I changed the JAVA_HOME to C:/PROGR~1/Java/jdk1.7.0_23 and in hadoop-env.sh I changed JAVA_HOME to /cygdrv/c/PROGRA~1/Java/jdk1.7.0_23.
It worked fine.
You set JAVA_HOME correctly. Now let's cd correctly too.
cd "$JAVA_HOME"
To avoid using the tedious Windows environment variables, and also use the actual path string copied from Windows explorer, I suggest adding the following to your startup script:
TMP=`cygpath -sw "C:\Program Files\Java\jdk1.8.0_31"`
export JAVA_HOME=`cygpath -u $TMP`
The first cygpath invocation obtains a short, windows path; the second converts it to unix format, which works fine in cygwin.
This will also now work fine:
$ cd $JAVA_HOME
Try to use short name to avoid a space in a path.
"C:\Program Files" should have short name C:\Progra~1 (you can verify it using DOS dir command or entering it into address bar in file explorer).
Set your JAVA_HOME this way:
export JAVA_HOME="/cygdrive/c/Progra~1/Java/jdk1.7.0_10"
Try using the DOS subst command to take the spaces of the JAVA_HOME path name.
Assuming drive J; is not mounted or otherwise used.
In a DOS shell
subst j: "C:/Program Files/Java/jdk1.7.0_45"
J: is now an abbreviation for C:/Program Files/Java/jdk1.7.0_45
You can now cd to J:
now run Cygwin and
export JAVA_HOME="J:"
I installed Java outside of "Program Files", specifically in c:\tools. Then you can use cygpath to convert the C:\tools\jdk1.8.0_144 to /cygdrive/c/tools/jdk1.8.0_144
on MSYS2 terminal
checke for previous claim:
ls "/C/program files/" !works! -thats for long file names so, to the point:
export JAVA_HOME="/D/Devel/jdk-12.0.2"
And now maven works....
check:
user55#DESKTOP MSYS ~
# echo $JAVA_HOME
/D/Devel/jdk-12.0.2

Resources