2

I'm using TextMate 2.0-alpha.9427 on OS X 10.8.2. Since two days, when I run a script (Python or shell script), instead of the directory of the script itself, the current working directory is something like /private/var/folders/0r/y4qmws5d2tjdkqzlb19_ny1h0000gn/T.

I think this behaviour appeared with the last TextMate alpha release, but reverting to the previous version was useless. Any ideas?

slhck
  • 223,558
  • 70
  • 607
  • 592
Aristide
  • 123
  • 4
  • 1
    As TextMate 2 is bleeding edge alpha, you should probably file a bug with them instead. – slhck Jun 03 '13 at 13:20
  • @slhck Well, I'm not sure this is a bug. May be I just need to tweak some environment variable in the prefs. I'll surely file a bug otherwise. Thanks! – Aristide Jun 03 '13 at 14:11

1 Answers1

4

https://github.com/textmate/textmate/blob/master/Applications/TextMate/about/Changes.md:

The working directory of the command being executed is unspecified except for drop commands (where it is the parent of the current file). We have never documented what the working directory is set to, and if you need it to be set to something specific (e.g. TM_PROJECT_DIRECTORY) then you should set it yourself.

I don't know how you're supposed to change the working directory though. Setting PWD to $TM_PROJECT_DIRECTORY in the variables tab didn't work. As a temporary measure, I added this to the commands for running scripts in the Ruby and shell script bundles:

Dir.chdir(ENV["TM_PROJECT_DIRECTORY"])
Lri
  • 40,894
  • 7
  • 119
  • 157
  • Thanks! Following your advice, I've added the following to the command for running Python scripts: `Dir.chdir(ENV["TM_DIRECTORY"])` (i.e., the folder of the current document). It works fine! – Aristide Jun 04 '13 at 08:14