Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata wont change working directory from do file after update

    Hi, after installing the most recent Stata update whenever I try to set a working directory from a do file I will get the following error:

    cd "C:\Users\Dodo\Desktop\projects\fta"
    unable to change to C:\Users\Dodo\Desktop\\projects\fta
    r(170);

    According to the Stata documentation, an error r(170) means that cd was unable to change to the directory you typed because either it does not exist, it is protected, or it is not a directory (moreover, it says that this error is only for Linux or Mac - but I have windows 7).

    However, this can't be true as I can still change the working directory manually outside do file but doing so is incredibly annoying. Moreover, before the same do file worked fine and I did not change any setting in windows. The only thing that preceded this was installing the latest update which was shown on the initial result display screen after the start of a program.

    Moreover, all other commands in do file work fine except for the cd. Is there any way to make it work again?

    Thanks in advance for any help!

  • #2
    Are you absolutely certain you have appropriate permissions for that directory and have not mistyped its name or path?

    If yes, then the most likely explanation is that your updated installation is somehow incomplete or got corrupted in transmission somehow. This happens from time to time. I would start by just running -update all, force-. I would also restart the computer after that. This is likely to solve your problem, so try again.

    If that doesn't do the trick, go to https://www.stata.com/support/instal...qualification/ and install the installation qualification tool and run it. It will identify any parts of your Stata installation that are incorrect.

    Comment


    • #3
      I tend to agree with Clyde's diagnosis. But if you want to try further debugging, copy and paste the following into your Do-file Editor window, run it, and see if the results add any enlightenment.
      Code:
      cd "C:\Users\"
      dir
      cd "C:\Users\Dodo\"
      dir
      cd "C:\Users\Dodo\Desktop\"
      dir
      cd "C:\Users\Dodo\Desktop\projects\"
      dir
      cd "C:\Users\Dodo\Desktop\projects\fta\"
      dir

      Comment


      • #4
        Jozef,

        you will get an error message that you quoted on a Windows platform if a file exists with the same name and you are trying to change directory into a file. This is obviously invalid.

        Best, Sergiy Radyakin

        Example on a Windows 7/Stata 14 combination:
        Code:
        . findfile auto.dta
        Q:\Stata14\ado\base/a/auto.dta
        . cd "`r(fn)'"
        unable to change to Q:\Stata14\ado\base/a/auto.dta
        r(170);
        PS: I don't think it is possible to have a file and a folder in Windows with the same name in the same folder
        https://unix.stackexchange.com/quest...-the-same-name
        so check if your original project folder has survived.
        Last edited by Sergiy Radyakin; 15 Dec 2017, 14:10. Reason: Added example

        Comment

        Working...
        X