Given this scenario:
K:\>dir
...
some_dir
job_1
...
K:\>cd some_dir
K:\some_dir> C:
C:\> cd script
C:\script> ruby processor.rb
You would expect this output...
In job job_1
Instead, we receive no output at all! Why?
Gotcha(s):
- Changing drives in DOS/Windows is a separate action from changing the CWD for a drive.
- Changing the working path to a different drive requires 2 steps.
- When
Dir.chdir
ing to a non-root path on Windows, Ruby combines these steps to be more Unix-like. When passed a root path, however, it defers to whatever DOS'CWD
is stored. Unfortunately, when you change drives in a DOS/Windows environment, your CWD for that drive is remembered!
As a result, in the above scenario, changing dir to ROOT_PATH
(which we know to be K:) actually changes dir to K:\some_dir
!
Solutions: Add a trailing / to the ROOT_PATH
variable.