Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66623

LANG not inherited in process environment on MacOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.10.0
    • Core: Locales (i18n)
    • None
    • MacOS 10.13.3
    • macOS

    Description

      On Linux LANG is present in the list of environment variables returned by QProcessEnvironment::systemEnvironment().  However, on MacOS LANG is not present, as you can see from the output of QProcessEnvironment::systemEnvironment().toStringList().join('\n'):

       

      Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.SQQgYPhgxv/Render
      HOME=/Users/richard
      LOGNAME=richard
      PATH=/usr/bin:/bin:/usr/sbin:/sbin
      SHELL=/bin/bash
      SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Ux4q7g4U0B/Listeners
      TMPDIR=/var/folders/b_/xb2y4mrn2nd87ph_3tz2hsbc0000gn/T/
      USER=richard
      XPC_FLAGS=0x0
      XPC_SERVICE_NAME=com.inviska.Inviska MKV Info.5144
       __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2

       

      Running "printenv LANG" in a MacOS console returns "en_GB.UTF-8", so LANG is definitely defined in the system environment.  You would therefore expect it to be inherited in the process environment, which on Linux it is, but on MacOS it isn't.

      The documentation for QProcessEnvironment::systemEnvironment() says, "The systemEnvironment function returns the environment of the calling process."  LANG is defined in the calling process, but isn't being returned by systemEnvironment(), so there is an issue where that function isn't doing what the documentation says.

      The absence of LANG in the process environment can also create problems when running a program in a QProcess.  For example, the MKVToolNix command line tools do not function correctly if LANG is not defined, so if you run it in a QProccess on MacOS it doesn't work properly.  You therefore have to manually define LANG with QProcess::setEnvironment().

      A process would normally inherit the parent processes environment variables, but with Qt on MacOS that doesn't seem to be happening.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            inviska Richard Craig
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes