Closed larsvilhuber closed 1 year ago
Our guidance to RAs that specifically addresses this is here: https://github.com/labordynamicsinstitute/replicability-training/wiki/Stata-Tips#file-___-could-not-be-opened-error
Note that another workaround is to cd
to the relevant directory first (while keeping the network-drive notation), then the command runs fine. Again, this is not a sustainable solution (cd-ing all over the place is not desirable either).
I wonder if there's another workaround that might work. When Stata encounters a file path with forward slashes, if it is on Windows, it will transparently interpret them as backslashes. This is because a folder like Dropbox/BigProject/main.do
on macOS will appear on Windows as Dropbox\BigProject\main.do
. In my collaborative projects, I always encourage my team members to use forward slashes everywhere, because Stata will not interpret backslashes as forward slashes on non-Windows operating systems.
However, I have not tried this with double-backslash network paths.
In other words, what happens if you set
global root "//rschfs1x/userrs/xxxxx/Desktop/workspace/yyyyy"
global tabs "$root/SUBMITTED_V3/Output/Tables"
or even the weirder
global root "//rschfs1x\userrs\xxxxx\Desktop\workspace\yyyyy"
global tabs "$root\SUBMITTED_V3\Output\Tables"
@NilsEnevoldsen All of those work, but that's not the problem.
The first problem is that esttab
(and only esttab
) removes one of the double slashes, which is inappropriate here. Every other use of the path $root
however written works. Which suggests that there is some esttab
-specific string processing of the output file path happening.
The second problem is we never actively set the path. Stata does:
global root : pwd
So we only go in and actively hard-code a path when somebody uses esttab
. And only then.
PS: MWE with Linux, Windows with drive letters, and Windows with network drives log files: https://github.com/larsvilhuber/mwe-esttab-issue58
Hi, the issue is that in Stata's macro expansion backslash sometimes has a meaning; an effect of this is that \\
typically expands to \
. The double backslash can be preserved by using `macval(lname)'
for macro expansion instead of `lname'
. In the latest commit I now changed estout
and esttab
to use macval()
with all macros containing file names. Please let me know if Windows network paths work now.
I ran the MWE with the latest update, and it works! Thanks for solving it (and now I learned yet another thing about Stata programming).
Here's the successful logfile:
(you can see the version of estout
used in https://github.com/larsvilhuber/mwe-esttab-issue58/blob/main/logs/logfile__9_Apr_2023-20_23_39-lv39_RS.log#L46)
From my point of view, this can be closed.
When using
esttab
with a Windows computer using a network path, it seems to sanitize the path in a way that makes it fail.Example:
where
(and
SUBMITTED_V3\Output\Tables
exists) Typical output isbut
esttab
fails with(note the
\rschfs1x
instead of the\\rschfs1x
). This only appears to happen withesttab
, and can be avoided (on the same computer) by usingglobal root "U:/Desktop\workspace\yyyyy"
instead. However, this is not desirable, because the automatic detection of pathnames yields the network path, not the Drive-letter path (to avoid the problem means hard-coding paths all over the place).My suspicion is that something related to the LaTeX processing of
esttab
is "sanitizing" the path before attempting to write it out.Happy to help debug on a Windows computer with such network paths, if not available to you.