From: Markus Schirp Date: 2009-09-21T03:10:49+09:00 Subject: Re: Thread-safe FileUtils.cd Forcing the users to use absolute paths may just hides the problem. Maybe you should expand the users "relative" paths before using them. Or monkeypatch FileUtils, and maybe dozens ruby core classes to support a "thread-safe" cwd. James Coglan wrote: > 2009/9/20 Markus Schirp > >> The current working process is a global property of the underlaying system >> process. >> >> A system Process has one currency working directory, not two, or more. >> >> You can do your directory / filename calculations, using the absolute >> directory path, without any race conditions. > > > Yes, I realise now I should have forced users to use absolute paths, but as > it stands there's code out in the wild with stuff like: > > hook :after_build do |build| > FileUtils.cp 'README', File.join(build.build_dir, 'README') > end > > So the working directory needs to be set so that 'README' can be found > correctly. Internally the tool uses absolute paths, so e.g. > `build.build_dir` is an absolute path, but code written by users is likely > to use relative paths. >