Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to run 'aws' from cygwin

I'm using cygwin installed on Windows 10 and trying to access awscli from it.

I used pip install awscli to install awscli. This installed awscli. I then tried to run only aws to see if it is installed and I get the following error:

-bash: /cygdrive/c/Program Files/Anaconda2/Scripts/aws: C:\Program: bad interpreter: No such file or directory

I'm not sure why this is happening. Any help in this regard would be highly apreciated.

like image 826
Patthebug Avatar asked Oct 24 '16 05:10

Patthebug


3 Answers

This is still an issue even with the latest version of AWS cli. So after some trial and error I found a pretty good workaround that will not make you switch your favorite shell.

First, make sure python is on your PATH. That is from anywhere in the system you can just run python and it work.

Find the aws script and open it for editing (for me it was located in c:\Program Files\Python36\Scripts\aws) and change the hashbang (that would be the first line in the script) to #!python.exe. For me it was set to #!c:\Program Files\Python36\python.exe. That space in the middle of Program Files caused the issue when that path got converted to Linux like path. Changing it to #!python.exe sidesteps the issue.

When you update AWS cli, repeat the workaround.

PS. You could also avoid this issue by installing python somewhere in a folder without spaces in path. That requires to reconfigure your system, so I did not do that myself.

like image 110
Mike Starov Avatar answered Oct 19 '22 10:10

Mike Starov


I would install the standard python and ensure it is coming up first in your path with which python and which pip. Path issues like this are due to mixing and matching executables targeting different platforms in my experience. Certain commands do not implement functionality to convert paths from Windows to Linux and back (it appears your specific commands are failing on spaces).

Since you say you are on Windows 10, if you have the anniversary edition, I would recommend Windows Subsystem for Linux over cygwin. You will likely see less Windows issues on WSL since it uses the exact same ubuntu packages you would use on Linux instead of the cygwin port and maps them low level to the NT Kernel.

like image 26
cchamberlain Avatar answered Oct 19 '22 10:10

cchamberlain


The Problem comes from "Program Files" having a space. This is something that is related to cygwin (I encountered the same error with git bash on windows). In a script I had something like this:

#!/c/Program Files/some_program/executable.exe

Escaping the space with a backslash or using quotes didn't work.

The solution is to use the DOS' short filename:

  • Progra~1 for "Program Files"
  • Progra~2 for "Program Files (x86)"

So my line would turn into:

#!/c/Progra~1/some_program/executable.exe
like image 1
Younes El Ouarti Avatar answered Oct 19 '22 08:10

Younes El Ouarti