Hello everyone,
I've gotten stumped by a repeated issue loading files through long paths.
To put it briefly, I am trying to load a file in another directory through a long relative path, from a pwd with a long path itself. I can confirm that the target directory exists, and that the file in it exists. I can cd to the target directory via the relative path, and after doing so can load the file by just its name. But I can't load the file through its relative path, from the original pwd.
I've tried experimenting, and this issue appears to arise when a pwd + relative path concatenated is >260 characters (the traditional value of the MAX_PATH environment variable in Windows).
The thing is, I'm running Stata 17.0 MP4 on Windows 10 release 21H1, with long paths enabled. I don't think this should be a binding system limit. Has anybody else run into this issue?
Some example code illustrating the issue is below:
Note that in this snippet the files/directories with the x's are ones where I've masked the name for this post, replacing every character with 'x' but keeping it the same length.
The only closely related thread I've found is this one, but it didn't help me crack this.
Thanks in advance!
Dan
I've gotten stumped by a repeated issue loading files through long paths.
To put it briefly, I am trying to load a file in another directory through a long relative path, from a pwd with a long path itself. I can confirm that the target directory exists, and that the file in it exists. I can cd to the target directory via the relative path, and after doing so can load the file by just its name. But I can't load the file through its relative path, from the original pwd.
I've tried experimenting, and this issue appears to arise when a pwd + relative path concatenated is >260 characters (the traditional value of the MAX_PATH environment variable in Windows).
The thing is, I'm running Stata 17.0 MP4 on Windows 10 release 21H1, with long paths enabled. I don't think this should be a binding system limit. Has anybody else run into this issue?
Some example code illustrating the issue is below:
Code:
. pwd C:\Users\dgross\Dropbox (Personal)\Research\xxxxxx Project\Paper 1 (Main)\Analysis\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx . global usptoDir="../../../../Data Collection/USPTO Datasets" . local dirname="xxx Firms with Focal (Top 1000) Words" . local fname="xxx_token_matches_terms" . use "$usptoDir/Derivative Datasets/`dirname'/`fname'.dta", clear file ../../../../Data Collection/USPTO Datasets/Derivative Datasets/xxx Firms with Focal (Top 1000) Words/xxx_token_matches_terms.dta not found r(601); . confirmdir "../../../../Data Collection/USPTO Datasets/Derivative Datasets/xxx Firms with Focal (Top 1000) Words/" . disp _rc 0 . capture confirm file "../../../../Data Collection/USPTO Datasets/Derivative Datasets/xxx Firms with Focal (Top 1000) Words/xxx_token_matches_terms.dta" . disp _rc 601 . cd "../../../../Data Collection/USPTO Datasets/Derivative Datasets/xxx Firms with Focal (Top 1000) Words/" C:\Users\dgross\Dropbox (Personal)\Research\xxxxxx Project\Data Collection\USPTO Datasets\Derivative Datasets\xxx Firms with Focal (Top 1000) Words . capture confirm file "xxx_token_matches_terms.dta" . disp _rc 0
The only closely related thread I've found is this one, but it didn't help me crack this.
Thanks in advance!
Dan
Comment