In <notworking1>, note that <exec> does not space-separate the command line into args like the shell does (except under Windows, which does not have a concept of separate args at the OS level); this is so quotes/spaces/asterisks/etc. need not be escaped as in shell commands. So <exec "/bin/cmd option"> would try to exec the file `/bin/cmd option', not `/bin/cmd'. You're probably getting `Cannot exec `casperjs --version': No such file or directory' as the error: that message just prints what it thinks is the executable, not the args too, so seeing the arg(s) in there means they were glommed onto the exe. Use `<$script = "casperjs" "-version"><exec $script>...': make the command and each arg separate Vortex values.
Also, ENVSET affects the exec'd process environment, not Vortex's: so the search path for whatever you are <exec>ing is still Vortex's path, and is not affected by ENVSET. The ENVSET PATH will only affect what that exec'd `casperjs' itself tries to run.
In <notworking2>, in your `echo' statement, you're evaluating $PATH in Vortex, not the shell: so the script you are executing is not `echo $PATH' but `echo /whatever:/your:/vortex/script:/path/is:/not/what/ENVSET/set/it/too'. Use `echo $$PATH' instead (escape the dollar sign), so that the shell sees `echo $PATH'.
Same issue in <thisworks>: $PATH is evaluated in Vortex, not the shell, so you're running `PATH=/Vortex/path:/usr/local/bin' not `PATH=$PATH:/usr/local/bin'. It "works" because you have not set PATH (via ENVSET) before that point, so at that point the shell's $PATH is the same as Vortex's $PATH, so the net effect is the same. Again, escape var references in shell scripts that you want evaluated by the shell script instead of Vortex. (It also works with `<$script = "casperjs -version">' because you're letting the shell do its space-separation thing, because it is exec'ing casperjs, not Vortex. And again, `$script' is being evaluated in Vortex, not the shell.)
The problem that instigated this, /usr/local/bin not being in the web server's PATH, has been fixed. So
<exec "casperjs" "--version"></exec>
now works without fiddling the PATH in vortex.
Just for the record, would this have been a solution? Setting the Vortex path using vxcp before the exec?
<$path ='%EXEDIR%:%BINDIR%:%SYSLIBPATH%:/usr/bin:/usr/local/bin'>
<vxcp libpath $path>
No; <vxcp libpath> affects shared libs. <strfmt "%s:/usr/local/bin" $PATH><syscp setenv PATH $ret> would have added /usr/local/bin to the search path for the <exec>.