I'm a new TextMate user trying to write a simple bundle command to launch my g++ builds from TextMate. Leaving out the stuff to HTMLify the results (which doesn't seem to make a difference to this bug), it looks like this:
cd ${TM_PROJECT_DIRECTORY} ./build.sh
Where build.sh is a script which calls make on a series of makefiles, checking the result each time. It works fine if I call it from the command line. But when I trigger the command in TextMate, the compiles work fine, but ar calls ("ar crv") to build the library fail pretty consistently with errors like this:
ld: in ../hw_nmtlib_core.a(__debug_frame), not a valid archive member
The error is apparently in the .a file, as executing build.sh from the command line will still generate the error, until you force it to regenerate the .a file.
I'm hoping someone has an idea what might be going on here, because TextMate will be a dream if I can get this working properly.
Thanks, Sol
On 4 Dec 2008, at 13:16, Sol Foster wrote:
[...] I'm hoping someone has an idea what might be going on here, because TextMate will be a dream if I can get this working properly.
My best guess is that you have more than one version of the shell commands involved, and TextMate uses another one due to different PATH setting.
When your command does not have a shebang, TextMate will source your profiles to try and get the same environment as a Terminal session, you can bypass this by putting a shebang in your command (e.g. #!/bin/ sh).
For more details see http://manual.macromates.com/en/shell_commands.html#search_path
Although if you say it works in Terminal, it does sound like you want the behavior, although if you are using something other than bash in Terminal, the environment will not be the same. Anyway, the environment is what you want to look at, particularly the PATH variable.
Allan Odgaard <mailinglist@...> writes:
On 4 Dec 2008, at 13:16, Sol Foster wrote:
[...] I'm hoping someone has an idea what might be going on here, because TextMate will be a dream if I can get this working properly.
My best guess is that you have more than one version of the shell commands involved, and TextMate uses another one due to different PATH setting.
When your command does not have a shebang, TextMate will source your profiles to try and get the same environment as a Terminal session, you can bypass this by putting a shebang in your command (e.g. #!/bin/ sh).
For more details see
http://manual.macromates.com/en/shell_commands.html#search_path
Although if you say it works in Terminal, it does sound like you want the behavior, although if you are using something other than bash in Terminal, the environment will not be the same. Anyway, the environment is what you want to look at, particularly the PATH variable.
I added "which ar" to the build script, and it was the same whether I fired it off from Terminal or TextMate. But following this idea, I dumped the environment in the build script and compared Terminal and TextMate.
Bingo! When executed from TextMate, COMMAND_MODE=legacy; from the Terminal it's COMMAND_MODE=unix2003. Apparently ar behaves differently depending on the two settings. I don't know how to change that in TextMate (or why it is different), but it was easy enough to add COMMAND_MODE=unix2003 to my build script, and now the builds work just fine.
Thanks!
--Sol
On 6 Dec 2008, at 16:02, Sol Foster wrote:
[...] Bingo! When executed from TextMate, COMMAND_MODE=legacy; from the Terminal it's COMMAND_MODE=unix2003. Apparently ar behaves differently depending on the two settings. I don't know how to change that in TextMate (or why it is different), but it was easy enough to add COMMAND_MODE=unix2003 to my build script, and now the builds work just fine.
Wasn’t aware of this, but some details in “man 5 compat”.
My best guess is that launchd sets this for applications it launches based on their deployment target, since TM is built for OS 10.4 it gets the value set to “legacy”.