Let's make RAILS_ROOT an absolute path on Windows

As this Caboose article [] suggests, I am not the only one who had
this problem. RAILS_ROOT is a relative path on Windows, and it can
bite you in unexpected ways. I had that problem while working on
CruiseControl.rb.

There is a trivial patch fixing it (by simply applying
File.expand_path to the path before assigning it into the RAILS_ROOT
constant): http://dev.rubyonrails.org/ticket/7259

Best regards,
Alex Verkhovsky

Oops, the missing link was http://i.nfectio.us/articles/2007/02/10/rails_root-and-dir-chdir

expand_path doesn't play nice with symlinks, so RAILS_ROOT will be set
to deploy_dir/releases/9374789394 instead of /current.

What in particular is breaking your application?

Right. Thanks for reminding me. We had exact same conversation two years ago, and I completely forgot about it by now.

Rails autoloading, and Kernel.require in general, breaks when you chdir into another directory after executing config/environment.rb. chdir invalidates all $: entries added by Rails, because all of them start from (relative) RAILS_ROOT.

You typically need to change the current working directory before executing external processes. A workaround is to wrap every shell command within its own chdir block. It’s not too hard to do, just hard to remember.

Best regards,
Alex

I'd also like to switch to realpath instead of cleanpath...