Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINGW64 not supported #36

Closed
oliversalzburg opened this issue May 11, 2016 · 18 comments
Closed

MINGW64 not supported #36

oliversalzburg opened this issue May 11, 2016 · 18 comments

Comments

@oliversalzburg
Copy link

When I use chalk (or anything else that depends on this module), output is not colored by default and must be forced with CLI arguments.

@sindresorhus
Copy link
Member

sindresorhus commented May 11, 2016

What do you get when running the following:

$ node -p -e "Boolean(process.stdout.isTTY)"

See: nodejs/node#3006 (comment)

@oliversalzburg
Copy link
Author

oliversalzburg commented May 11, 2016

$ node -p -e "Boolean(process.stdout.isTTY)"
true

That is unexpected though, because I messed with the source earlier and made the following change to index.js:

    if (process.stdout && !process.stdout.isTTY) {
        console.log('I\'m not a TTY');
        return 0;
    }

Which would have the following result:

$ supports-color; echo $?
I'm not a TTY
1

@sindresorhus
Copy link
Member

I don't see why those checks would return differently...

@oliversalzburg
Copy link
Author

Ah, I guess it's because supports-color would be invoked through /bin/sh, but when I invoke node directly, the additional layer doesn't exist.

@sindresorhus
Copy link
Member

What does the following return?

$ node -p "process.env"

@oliversalzburg
Copy link
Author

$ node -p "process.env"
{ ACLOCAL_PATH: '/mingw64/share/aclocal:/usr/share/aclocal',
  ALLUSERSPROFILE: 'C:\\ProgramData',
  ANDROID_HOME: 'C:\\Program Files (x86)\\Android\\android-sdk',
  ANT_HOME: 'C:\\Program Files (x86)\\WinAnt',
  APPDATA: 'C:\\Users\\OliverSalzburg\\AppData\\Roaming',
  AWE_DIR: 'C:\\Program Files (x86)\\Khrona LLC\\Awesomium SDK\\1.6.6\\',
  COMMONPROGRAMFILES: 'C:\\Program Files\\Common Files',
  'CommonProgramFiles(x86)': 'C:\\Program Files (x86)\\Common Files',
  CommonProgramW6432: 'C:\\Program Files\\Common Files',
  COMPUTERNAME: 'OLIVER-NEW',
  COMSPEC: 'C:\\WINDOWS\\system32\\cmd.exe',
  DISPLAY: 'needs-to-be-defined',
  DNX_HOME: '%USERPROFILE%\\.dnx',
  ERLANG_HOME: 'C:\\Program Files\\erl7.2.1',
  EXEPATH: 'C:\\Program Files\\Git',
  FPS_BROWSER_APP_PROFILE_STRING: 'Internet Explorer',
  FPS_BROWSER_USER_PROFILE_STRING: 'Default',
  FP_NO_HOST_CHECK: 'NO',
  HOME: 'C:\\Users\\OliverSalzburg',
  HOMEDRIVE: 'C:',
  HOMEPATH: '\\Users\\OliverSalzburg',
  HOSTNAME: 'oliver-new',
  INFOPATH: '/usr/local/info:/usr/share/info:/usr/info:/share/info:',
  JAVA_HOME: 'C:\\Program Files (x86)\\Java\\jdk1.7.0_55',
  LANG: 'en_US.UTF-8',
  LOCALAPPDATA: 'C:\\Users\\OliverSalzburg\\AppData\\Local',
  LOGONSERVER: '\\\\SBS',
  MAGICK_CONFIGURE_PATH: 'C:\\Program Files (x86)\\OpenShot Video Editor\\ImageMagick\\etc\\configuration',
  MANPATH: '/mingw64/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man:',
  MSYSTEM: 'MINGW64',
  NUMBER_OF_PROCESSORS: '8',
  OS: 'Windows_NT',
  PATH: 'C:\\Users\\OliverSalzburg\\bin;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\local\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Users\\OliverSalzburg\\bin;C:\\Program Files (x86)\\Business Objects\\Common\\3.5\\bin\\NOTES;C:\
\Python27;C:\\Python27\\Scripts;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Business Objects\\Common\\3.5\\bin\\NOTES;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0;C:\\Program Files\\Microsoft DNX\\Dnvm;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn;C:\\Progr
am Files (x86)\\PuTTY;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files (x86)\\Skype\\Phone;C:\\Program Files\\Git\\cmd;C:\\Program Files (x86)\\pgmodeler;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn;C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance Toolkit;C:\\Program Files (x86)\\Microsoft Emulator
 Manager\\1.0;C:\\Program Files\\nodejs;C:\\Program Files (x86)\\Android\\android-sdk\\build-tools\\23.0.1;C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools;C:\\Program Files (x86)\\Android\\android-sdk\\tools;C:\\Users\\OliverSalzburg\\.dnx\\bin;C:\\Program Files\\nmap-7.01;C:\\Python27;C:\\Program Files (x86)\\WinAnt\\bin;C:\\Program File
s (x86)\\Microsoft VS Code\\bin;C:\\Users\\OliverSalzburg\\AppData\\Roaming\\npm;C:\\Program Files\\Git\\usr\\bin\\vendor_perl;C:\\Program Files\\Git\\usr\\bin\\core_perl',
  PATHEXT: '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.py;.pyw',
  PGMODELER_APP_PATH: 'C:\\Program Files (x86)\\pgmodeler\\pgmodeler.exe',
  PGMODELER_CHANDLER_PATH: 'C:\\Program Files (x86)\\pgmodeler\\pgmodeler-ch.exe',
  PGMODELER_CLI_PATH: 'C:\\Program Files (x86)\\pgmodeler\\pgmodeler-cli.exe',
  PGMODELER_LANG_DIR: 'C:\\Program Files (x86)\\pgmodeler\\lang',
  PGMODELER_PLUGINS_DIR: 'C:\\Program Files (x86)\\pgmodeler\\plugins',
  PGMODELER_SAMPLES_DIR: 'C:\\Program Files (x86)\\pgmodeler\\samples',
  PGMODELER_SCHEMAS_DIR: 'C:\\Program Files (x86)\\pgmodeler\\schemas',
  PGMODELER_TMPL_CONF_DIR: 'C:\\Program Files (x86)\\pgmodeler\\conf',
  PGPASSWORD: 'postgres',
  PKG_CONFIG_PATH: '/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig',
  PLINK_PROTOCOL: 'ssh',
  PRINTER: 'Brother MFC-9460CDN Printer',
  PROCESSOR_ARCHITECTURE: 'AMD64',
  PROCESSOR_IDENTIFIER: 'AMD64 Family 21 Model 2 Stepping 0, AuthenticAMD',
  PROCESSOR_LEVEL: '21',
  PROCESSOR_REVISION: '0200',
  ProgramData: 'C:\\ProgramData',
  PROGRAMFILES: 'C:\\Program Files',
  'ProgramFiles(x86)': 'C:\\Program Files (x86)',
  ProgramW6432: 'C:\\Program Files',
  PS1: '\\[\\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\\007\\]\\n\\[\\033[32m\\]\\u@\\h \\[\\033[35m\\]$MSYSTEM \\[\\033[33m\\]\\w\\[\\033[36m\\]`__git_ps1`\\[\\033[0m\\]\\n$ ',
  PSModulePath: 'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\',
  PUBLIC: 'C:\\Users\\Public',
  PWD: '/',
  QT_PLUGIN_PATH: 'C:\\Program Files (x86)\\OpenShot Video Editor\\',
  SESSIONNAME: 'Console',
  SHELL: 'C:\\Program Files\\Git\\usr\\bin\\bash',
  SHLVL: '1',
  SSH_AGENT_PID: '14728',
  SSH_ASKPASS: '/mingw64/libexec/git-core/git-gui--askpass',
  SSH_AUTH_SOCK: '/tmp/ssh-FIVLZ6b5Z6az/agent.14708',
  SYSTEMDRIVE: 'C:',
  SYSTEMROOT: 'C:\\WINDOWS',
  TEMP: 'C:\\Users\\OLIVER~1\\AppData\\Local\\Temp',
  TERM: 'xterm-256color',
  TMP: 'C:\\Users\\OLIVER~1\\AppData\\Local\\Temp',
  TMPDIR: 'C:\\Users\\OLIVER~1\\AppData\\Local\\Temp',
  USERDNSDOMAIN: 'HARTWIG.LOCAL',
  USERDOMAIN: 'HARTWIG',
  USERDOMAIN_ROAMINGPROFILE: 'HARTWIG',
  USERNAME: 'OliverSalzburg',
  USERPROFILE: 'C:\\Users\\OliverSalzburg',
  VS110COMNTOOLS: 'C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\Tools\\',
  VS120COMNTOOLS: 'C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Tools\\',
  VS140COMNTOOLS: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\',
  VSSDK140Install: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VSSDK\\',
  WINDIR: 'C:\\WINDOWS',
  _: '/usr/bin/winpty' }

@sindresorhus
Copy link
Member

Hmm, I'm out of ideas. Can you make sure you're running the latest version of Node.js and the latest version of Git for Windows (follow nodejs/node#3006 (comment)).

@oliversalzburg
Copy link
Author

I was some minimal updates behind, but updated both now:

$ node --version; git --version
v4.4.4
git version 2.8.2.windows.1

The result is still the same.

So, what I'm taking away from the issue you linked is that this is basically an issue of stdout not being identified as a TTY because MINGW does some piping in the background and is thus not a real TTY.

My environment above seems to indicate that MINGW will set MSYSTEM. So wouldn't it be possible to check for that and ignore the .isTTY check in that case?

@sindresorhus
Copy link
Member

sindresorhus commented May 11, 2016

Node.js 6.1.0 is the latest. Try that.

My environment above seems to indicate that MINGW will set MSYSTEM. So wouldn't it be possible to check for that and ignore the .isTTY check in that case?

I considered that. That's why I asked for the environment variables, but I realized that if we do this, it will still output colors if you actually pipe, which would be unexpected and incorrect.

Regardless, you would save yourself a lot of pain by just installing real Bash: https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/

@oliversalzburg
Copy link
Author

Oh well, yeah, I'll probably give the new Windows 10 Bash a try. Thanks

@Qix-
Copy link
Member

Qix- commented May 11, 2016

Just out of curiosity, do you have CYGWIN installed? I'd like to see if this is happening on your system with it vs. msys.

I wouldn't be surprised if msys was doing some strange piping.

@oliversalzburg
Copy link
Author

@Qix- I have CYGWIN as well, yeah. It doesn't have this problem:

Oliver@oliver-home ~
$ supports-color; echo $?
0

Different machine, but I doubt that has any relevance here.

I don't know why I decided at some point to use MINGW instead of CYGWIN. It definitely wasn't color support, that's for sure :P

@Qix-
Copy link
Member

Qix- commented May 11, 2016

MinGW is definitely superior in my personal opinion.

@oliversalzburg
Copy link
Author

Thanks for the tip :)

@Qix-
Copy link
Member

Qix- commented May 11, 2016

To be clear: the MinGW builds for LLVM/CLang are superior. I prefer CYGWIN for everything else, i.e. the command line. But then again I haven't used either of those for about a year now. 👍

@Qix-
Copy link
Member

Qix- commented May 11, 2016

I think this is a wontfix unfortunately - yes we can probably test specifically for MinGW, but we still wouldn't be able to detect if it was a TTY we were outputting to or some other program. That's a distinction you will have to make yourself via environment variables.

If you open a ticket with the MSYS group I'll definitely chime in on it.

@sindresorhus does that sound about right?

@sindresorhus
Copy link
Member

Yes

@emigenix
Copy link

emigenix commented Aug 25, 2016

Any updates on this issue? On Cygwin I get:

$ node -p -e "Boolean(process.stdout.isTTY)"
false

$ tput.exe colors
8

$ supports-color; echo $?
1

$ tty.exe
/dev/pty1

I wonder if this problem have anything to do with the terminal being a pseudo terminal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants