0

Probably more of a MacOS/zsh question than a Flutter question.

The error message is:

/bin/sh: exiftool: command not found

I am trying to call exiftool from my Flutter MacOS desktop app.

ProcessResult processResult = Process.runSync('exiftool', params, runInShell: true);

The params is just the path to the file.

I installed exiftool using brew. There's a symlink to it in /usr/local/bin. /usr/local/bin is in the path. I can call exiftool from the terminal without any error.

I run the application from Android Studio, and this only happens when Android Studio starts at start up and it also starts the application (I check the reopen applications checkbox when I reboot). If I close the application and Android Studio and restart them again, it works.

Is it possible that the environment is not completely set up when MacOS starts Android Studio ? Any way to mitigate this ?

Thank you.

D. Joe
  • 573
  • 1
  • 9
  • 17
  • Try using the complete path for exiftool. The application probably don't inherit PATH when launching. – kometen May 01 '21 at 15:36
  • Run `type exiftool` in Terminal to find the full path, then use that in your script. – Mark Setchell May 01 '21 at 15:49
  • @kometen That would ruin the app's portability. The idea is to be able to use it on any OS and computer regardless of the paths to exiftool and other tools, as long as those are in the PATH environment variable. – D. Joe May 02 '21 at 16:18
  • @MarkSetchell see my reply to @ kometen. I know I can do that, but that's not what I want. – D. Joe May 02 '21 at 16:18
  • It looks like your subprocess ran `/bin/sh` not `zsh`. If it works in Terminal that's because your PATH is set differently in Terminal. So, if you run `type exiftool` as I suggested, you will then find out what needs to be on your PATH, you should then be able to add that, and anything else you need to be portable on other platforms, to your `Process.run()`. – Mark Setchell May 02 '21 at 16:48
  • @D.Joe : _Probably more of a MacOS/zsh question_ : I don't see how zsh is involved here. – user1934428 May 05 '21 at 07:53
  • @user1934428 the problem might be it's not involved. I'd expect it to be, since Apple decided to use zsh as the default shell. Problem might be Android Studio and the Flutter app being started too soon and/or not in the correct env. – D. Joe May 06 '21 at 07:58
  • You are calling a sh-script from a Java application. If the login shell - which might be zsh - does not set up the environment correctly, this could be a cause, but then is is about setting up the environment, and you could verify the environment from within Java or inside your shell script, for debugging. – user1934428 May 06 '21 at 08:30
  • It's actually a Dart application. And this issue only seems to show up if Android Studio is started at boot. If restarted or started later, this doesn't show up. Which means it's something boot related, which very likely means something is not yet set up by the OS before Android Studio starts. I really don't know what your argument is. My app code is correct, so it seems to me that the OS starts Android Studio too soon. I think this points to some kind of race condition. Either way, there's nothing I can change from my app/config. – D. Joe May 06 '21 at 19:12

0 Answers0