Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"file could not be opened" error when running brewcolordb, replace #45

Closed
jdmarvel opened this issue Apr 12, 2016 · 9 comments
Closed
Assignees

Comments

@jdmarvel
Copy link

. brewcolordb, replace
------------------------------------------------------------------------- begin brewcolordb ---
- version 13.1
- syntax [, DISplay REPlace OVERride]
- if `"`override'"' == "" {
= if `""' == "" {
- di as res "This program needs to clear all data currently in memory. " "If this is ok hit ent
> er, otherwise enter the letter 'n' and hit enter " "to exit the program without clearing data
>  from memory." _request(_perm)
This program needs to clear all data currently in memory. If this is ok hit enter, otherwise en
> ter the letter 'n' and hit enter to exit the program without clearing data from memory.. 
- if lower(`"`perm'"') == "n" exit
= if lower(`""') == "n" exit
- }
- clear
  ----------------------------------------------------------------------------- begin clear ---
  - if _caller() < 10 {
    _clear_9 `0'
    exit
    }
  - version 10
  - syntax [anything]
  - tokenize `anything'
  = tokenize 
  - if `"`2'"' != "" {
  = if `""' != "" {
    display as err "`2' not allowed"
    exit 198
    }
  - if "`1'"=="" {
  = if ""=="" {
  - drop _all
  - label drop _all
    --------------------------------------------------------------------------- begin label ---
    - version 10.0
    - gettoken val : 0
    - if (strpos("`val'", "val") > 0 ) {
    = if (strpos("drop", "val") > 0 ) {
      gettoken val 0 : 0
      syntax anything [, nofix]
      if "`fix'" != "" {
      local fix ", nofix"
      }
      gettoken var rest : anything
      while `"`rest'"' != "" {
      gettoken lab rest : rest
      local label "`lab'"
      }
      local vlist : list anything - lab
      if "`lab'" == "." {
      local lab ""
      }
      foreach var of varlist `vlist' {
      _label `val' `var' `lab' `fix'
      }
      }
    - else {
    - _label `macval(0)'
    = _label drop _all
    - }
    ----------------------------------------------------------------------------- end label ---
  - }
  - else if "`1'"=="mata" {
  = else if ""=="mata" {
    mata: mata clear
    }
  - else if inlist("`1'", "results", "matrix") {
  = else if inlist("", "results", "matrix") {
    return clear
    clearreturn
    ereturn clear
    sreturn clear
    _return drop _all
    if ("`1'" == "matrix") {
    matrix drop _all
    _est drop _all
    }
    }
  - else if "`1'"=="programs" {
  = else if ""=="programs" {
    program drop _all
    }
  - else if "`1'"=="ado" {
  = else if ""=="ado" {
    program drop _allado
    }
  - else if "`1'"=="*" | "`1'"=="all" {
  = else if ""=="*" | ""=="all" {
    capture mata: st_local("semmods", strofreal(sg__global.hasmodels()))
    capture
    if (0`semmods') {
    display as err "-clear all- not allowed while an SEM Builder is open"
    exit 1
    }
    drop _all
    label drop _all
    matrix drop _all
    scalar drop _all
    constraint drop _all
    eq drop _all
    file close _all
    postutil clear
    _return drop _all
    discard
    program drop _all
    timer clear
    mata: mata clear
    }
  - else {
    display as err "`1' not allowed"
    exit 198
    }
  ------------------------------------------------------------------------------- end clear ---
- loc personal `"`c(sysdir_personal)'"'
= loc personal `"~/Library/Application Support/Stata/ado/personal/"'
- qui: dirfile, p(`"`: subinstr loc personal `"~"' `"`:environment HOME'"', all'brewcolors"')
= qui: dirfile, p(`"/Users/johnmarvel/Library/Application Support/Stata/ado/personal/brewcolors
> "')
  --------------------------------------------------------------------------- begin dirfile ---
  - version 13
  - syntax , Path(string) [ REBuild ]
  - cap confirm new file `"`path'"'
  = cap confirm new file `"/Users/johnmarvel/Library/Application Support/Stata/ado/personal/bre
> wcolors"'
  - if _rc == 0 {
    mkdir `"`path'"'
    di as res `"The directory `path' was successfully created."'
    }
  - else if _rc == 602 & "`rebuild'" != "" {
  = else if _rc == 602 & "" != "" {
    loc dirfiles : dir `"`path'"' files "*", respectcase
    forv i = 1/`: word count `dirfiles'' {
    di as res `"Delete the file `: word `i' of `dirfiles'' from `path' ? (Y/n)"' _request(_del)
    if inlist(`"`del'"', "y", "Y", "") {
    erase `"`path'/`: word `i' of `dirfiles''"'
    di as res `"Erased the file : `path'/`: word `i' of `dirfiles''"'
    }
    }
    loc dirfiles : dir `"`path'"' files "*", respectcase
    loc subdirs : dir `"`path'"' dirs "*", respectcase
    if `"`dirfiles'`subdirs'"' == "" {
    di as res `"`path' is empty.  Delete the directory too? (Y/n)"' _request(_del)
    if inlist(`"`del'"', "y", "Y") {
    qui: rmdir `"`path'"'
    }
    }
    }
  - else if _rc == 602 & "`rebuild'" == "" {
  = else if _rc == 602 & "" == "" {
    di as res "Directory exists and rebuild option not specified.  No further action"
    }
  - else if _rc == 603 & `"`c(os)'"' == "Windows" {
  = else if _rc == 603 & `"MacOSX"' == "Windows" {
    }
  - else {
  - err _rc
file could not be opened
    }
  ----------------------------------------------------------------------------- end dirfile ---
--------------------------------------------------------------------------- end brewcolordb ---
@wbuchanan wbuchanan self-assigned this Apr 12, 2016
@wbuchanan
Copy link
Owner

@jdmarvel can you confirm your ADOPATH variables? On the Non-*nix OS machine that I have at work it looks like:

. adopath
  [1]  (BASE)      "C:\Program Files (x86)\Stata14\ado\base/"
  [2]  (SITE)      "C:\Program Files (x86)\Stata14\ado\site/"
  [3]              "."
  [4]  (PERSONAL)  "c:\ado\personal/"
  [5]  (PLUS)      "c:\ado\plus/"
  [6]  (OLDPLACE)  "c:\ado/"

If nothing else you should be able to use:

! rm -r "/Users/johnmarvel/Library/Application Support/Stata/ado/personal/brewcolors"

To erase the existing directory and then the command should execute without a problem.

@jdmarvel
Copy link
Author

@wbuchanan my ADOPATH variables are shown below (I'm on a Mac with OS X Yosemite):

. adopath
  [1]  (BASE)      "/Applications/StataMP/ado/base/"
  [2]  (SITE)      "/Applications/StataMP/ado/site/"
  [3]              "."
  [4]  (PERSONAL)  "~/Library/Application Support/Stata/ado/personal/"
  [5]  (PLUS)      "~/Library/Application Support/Stata/ado/plus/"
  [6]  (OLDPLACE)  "~/ado/"

I ran the command you suggested above in the terminal, but get the message that no such file or directory exists. All brewscheme files are located in my /plus directory.

@wbuchanan
Copy link
Owner

I'm having difficulty replicating the issue you're running into. I just deleted all of the files/directories/subdirectories from my adopath and was able to install without fault:

. about

Stata/MP 14.1 for Mac (64-bit Intel)
Revision 30 Mar 2016
Copyright 1985-2015 StataCorp LP

Total physical memory:   16.00 GB

Single-user 8-core Stata perpetual license:
       Serial number:  XXXXXXXXXXXXXX
         Licensed to:  William Buchanan

. di `"`c(os)'"'
MacOSX

. adopath
  [1]  (BASE)      "/Applications/Stata/ado/base/"
  [2]  (SITE)      "/Applications/Stata/ado/site/"
  [3]              "."
  [4]  (PERSONAL)  "~/Library/Application Support/Stata/ado/personal/"
  [5]  (PLUS)      "~/Library/Application Support/Stata/ado/plus/"
  [6]  (OLDPLACE)  "~/ado/"

. ado, find(brewscheme)

. net inst brewscheme, from("http://wbuchanan.github.io/brewscheme/")
checking brewscheme consistency and verifying not already installed...
installing into /Users/billy/Library/Application Support/Stata/ado/plus/...
installation complete.

. brewcolordb, rep over
(142 real changes made)

@jdmarvel
Copy link
Author

weird. I replicated your sequence of commands from above (after deleting all files etc.) and still get the "file could not be opened" message.

. about

Stata/MP 14.1 for Mac (64-bit Intel)
Revision 30 Mar 2016
Copyright 1985-2015 StataCorp LP

Total physical memory:   16.00 GB

Single-user 4-core Stata perpetual license:
       Serial number:  xxxxxxxxxxxx
         Licensed to:  John Marvel

r; t=0.00 13:53:58

. di `"`c(os)'"'
MacOSX
r; t=0.00 13:54:15

. adopath
  [1]  (BASE)      "/Applications/StataMP/ado/base/"
  [2]  (SITE)      "/Applications/StataMP/ado/site/"
  [3]              "."
  [4]  (PERSONAL)  "~/Library/Application Support/Stata/ado/personal/"
  [5]  (PLUS)      "~/Library/Application Support/Stata/ado/plus/"
  [6]  (OLDPLACE)  "~/ado/"
r; t=0.00 13:54:22

. ado, find(brewscheme)
r; t=0.00 13:54:29

. net inst brewscheme, from("http://wbuchanan.github.io/brewscheme/")
checking brewscheme consistency and verifying not already installed...
installing into /Users/johnmarvel/Library/Application Support/Stata/ado/plus/...
installation complete.
r; t=5.63 13:54:43

. brewcolordb, rep over
file could not be opened
r(603); t=0.00 13:54:53

I'll try it on my work computer tomorrow to see if that makes a difference. Thanks for your help.

@wbuchanan
Copy link
Owner

Perhaps it is a file permissions issue? Do you have read/write permissions in the PERSONAL directory on the ADOPATH? The commands create several different files that all get placed there and others have had similar issues with file permissions on other platforms.

@jdmarvel
Copy link
Author

I checked into that and it doesn't appear to be the case. I navigated to my user folder, right clicked, selected "Get Info", and confirmed that the PERSONAL director has read/write permission.

@wbuchanan
Copy link
Owner

@jdmarvel have you had any luck with things since earlier this week? Another way you can check the file permission for the personal/plus ado paths is:

! ls -lah "/Users/johnmarvel/Library/Application Support/Stata/ado"

It will show the subdirectories in /Users/johnmarvel/Library/Application Support/Stata/ado and will list the permissions for each file/subdirectory that is found. The only other thing I can think of is perhaps that "/Users/johnmarvel/Library/Application Support/Stata/ado/personal/" doesn't exist at the moment (e.g., the location is defined in the macros used by Stata, but some times this directory doesn't exist on the users' computer).

@jdmarvel
Copy link
Author

@wbuchanan thanks for checking in. Your second thought was right. the /personal directory did not exist. I created it and things now work fine. Thanks very much for your help.

@wbuchanan
Copy link
Owner

@jdmarvel awesome! Glad to hear everything worked out well. Knowing that was the issue I'll try to add something that will check for that directory before doing anything else. This way it hopefully won't affect anyone else. The should be an updated version (what you already installed from the project page) available from the SSC archives in the not too distant future as well.

Thanks again

wbuchanan added a commit that referenced this issue Apr 15, 2016
… create the PERSONAL directory on the ADOPATH if it does not exist prior to attempting to build the local files used by brewscheme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants