cygwin bash

Answered

hi folks, i have:

IntelliJ IDEA 2016.3.2
Build #IU-163.10154.41, built on December 21, 2016
Licensed to _deleted_


JRE: 1.8.0_66-b18 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

on Windows 7 64 bit

 

i would like run cygwin bash as my terminal, but when in tools i set as a shell path: C:\cygwin\bin\bash.exe --login -i

i raise error "java.io.IOException: Couldn't create a PTY"

 

when i create a .bat file `bash.bat` and into i include 'C:\cygwin\bin\bash.exe --login -i' and run this .bat file, it works.

why?

13 comments
Comment actions Permalink

I'm using Git Bash in my IntelliJ and for the path I had to put quotes around the path for it to work.

e.g. "C:\Git\bin\sh.exe" --login -i

0
Comment actions Permalink

Try  "c:\cygwin64\bin\sh.exe" -c "/bin/xhere /bin/bash"

0
Comment actions Permalink

Try "c:\cygwin64\bin\sh" -lic "cd ${OLDPWD-.}; bash"

12
Comment actions Permalink

@Glli80's Answer worked for me! Thanks!

0
Comment actions Permalink

Choosing the path to Cygwin.bat in the root of Cygwin directory as the command worked for me. 

For me it was -

c:\software\cygwin\Cygwin.bat

0
Comment actions Permalink

I would like to improve the Glli80's answer (since by default my bash profile was not executed):

"c:\cygwin64\bin\sh" -lic "source ~/.bash_profile; cd ${OLDPWD-.}; bash"

1
Comment actions Permalink

Affkar's answer worked for me. I had to reread his comment to understand it's the root directory of the Cygwin folder (cygwin\Cygwin.bat) not the bin folder (cygwin\bin\Cygwin.bat). His answer also ran all of the profiles correctly.

 

0
Comment actions Permalink

thnak you for improving Esgorbachev

0
Comment actions Permalink
Adding -i --login to the shell path only partially works.
Your path will be set, but your "Start directory" will always be /home/[username] instead of the current project root.
 
I believe the root problem is that the Cygwin shell is executed by Idea using the full source path rather than using the environment PATH variable.  And since Cygwin doesn't add the /bin path to the Systems Environment Path, a lot of basic commands (like ls) aren't available when sourcing your .bash_profile and .bashrc files.
 
The solution is trivial.
Add your cygwin bash path (mine was: C:\cygwin64\bin) to your Windows System Environment Path variable. 
And take the -i and --ignore out of your shell path, like so:
 
 
Finally, clear any value you may have stored in the "Start directory" setting.  This will make your terminal open in the correct directory for each project.

You'll need to restart Idea so it sees the correct Path, but after that your Terminal Shell will work perfectly.
 
0
Comment actions Permalink

+1 on Dave's answer.

I was having nothing but problems getting IntelliJ to work with Cygwin + my bashrc + cd to project root.

Cygwin.bat calls `bash --login -i` from the bin directory; however, using `"C:\path\to\cygwin\bin\bash" -li` in IntelliJ would leave me at my home directory (the cd to project root wasn't working). Using the `sh -lic "cd here; bash"` trick to run a command and leave the terminal open was failing completely due to my cd function (pushd not available). Even tried `sh -c "cd here; bash -li". Nothing worked. That is, until I tried Dave's answer. I figured it wouldn't work, since `-li` seems to be important. However, I was so wrong.

  1. Ensure bin is in Path (you should have done this as part of your initial Cygwin installation). (Not 100% sure this is required, as I already had it set.)
  2. Call bash with no arguments. Shell path `C:\tools\cygwin\bin\bash`

My bashrc was processed and the terminal opens to the project root. So simple! Too simple to think it works, but it does.

0
Comment actions Permalink

@Derek White

Thanks Derek, Glad to help out.  It seems that every accepted solution out there (including StackExchange) goes with the incorrect "-li" approach.  Very frustrating.  It was nice to see that IntelliJ code actually behaves correctly when the env (Path) was correctly defined.

0
Comment actions Permalink

@Gill80's answer works great except for paths with spaces. To fix this do:

"c:\cygwin64\bin\sh" -lic 'cd "${OLDPWD-.}"; bash'

The additional double quotes will force the environment variable into a single entity even if it has a space.

0
Comment actions Permalink

@Glli80's Answer worked for me! Thanks!

0

Please sign in to leave a comment.