"command not found" with user run script and xcodebuild

I am running a customized script that includes a command (ios-sim) that should be known by bash (the binary is in / usr / local / bin, $ PATH knows). However, when you call xcodebuild in the console logs, "command not found."

I can execute the command manually, but I have no idea why it does not work in the run script. I checked the user, but, as I expected, both times the same user ...

The line calling ios-sim:

ios-sim launch $(dirname $TEST_HOST) $environment_args --args -SenTest All $test_bundle_path -v 
+4
source share
1 answer

Instead of relying on $PATH , whose meaning is not obvious, use the entire path to ios-sim .

Modify your custom script and change:

 ios-sim launch ... 

to

 /usr/local/bin/ios-sim launch ... 

The reason that using $PATH can be dangerous (perhaps a word too strong) is because it is not obvious where it is installed. For example, Xcode will use the path that is configured in /etc/launchd.conf and /usr/local/bin may have been added to /etc/profile or ~/.bash_profile .

  • Will launchd use the value in /etc/profile and thus pass it to Xcode for use?
  • Scripts running with Xcode use /etc/profile or ~/.bash_profile ?

This complex and deep understanding of this environment will undoubtedly allow you to invoke your command through $PATH , however, using the full path to the command is a simple approach that will always work.

+7
source

All Articles