-2

I'm tryin get loaction of node package. Using QProcess to execute commang which node:

QProcess process;
process.start("/usr/bin/which", QStringList() << tr("node"));
process.waitForFinished(-1);
response = process.readAllStandardOutput();
qDebug() << response;

But in debug I got "".

Project located on GitHub. Problem in https://github.com/Dissfall/nodeGator/blob/develop/mainwindow.cpp

dissfall
  • 11
  • 6

1 Answers1

1

It may depend under what shell is running your app in QtCreator and under what one in terminal (bash/sh/csh etc.). The PATH variable may differ;

  1. u can check process.exitCode() i.e. when 'which' doesn't find tool, it return 1; otherwise 0
  2. may be, try to list the env. with:

    qDebug() << "env:" << QProcessEnvironment::systemEnvironment().toStringList();
    

You can see actual settings in QtCreator -> Projects -> ur KIT -> Run and "Run Environment" details. There is an option to set in which environment the app is running: build/system/clear - try change.

Ľubomír Carik
  • 387
  • 5
  • 11
  • Thanks for answer. First way is worked. It's wery helpfull for me. I checked environment variables. In this moment `SHELL=/bin/bash`. – dissfall Apr 24 '18 at 17:55
  • This turned out to be really valuable. The app was not working from Qt-Creator, but it was working if I execute the binary independently from the build folder. Thanks. – C-- Aug 16 '18 at 16:12