worldbank / ietoolkit

Stata commands designed for Impact Evaluations in particular, but also data work in general
https://worldbank.github.io/ietoolkit/
MIT License
211 stars 74 forks source link

`ieboilstart, adopath()` - make sure command works with `net set` #337

Open kbjarkefur opened 1 year ago

kbjarkefur commented 1 year ago

This feedback was orginally provided by Daniel Klein here.

Investigate how net set relates to the settings done in ieboilstart, adopath().

If the two features cannot be made to work together, then at least make sure that it is well documented that adopath() is cannot be used together with net set.

kbjarkefur commented 1 year ago

I was able to reproduce this problem. This example confirms that someone that has set net set ado to something else than PLUS will be able to install commands after using adopath() but the commands are not made available. See reproducible example here:

. * Show default setting
. sysdir
   STATA:  C:\Program Files\Stata17\
    BASE:  C:\Program Files\Stata17\ado\base\
    SITE:  C:\Program Files\Stata17\ado\site\
    PLUS:  c:\ado\plus\
PERSONAL:  c:\ado\personal\
OLDPLACE:  c:\ado\

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

. net query
from    http://www.stata.com
ado     c:\ado\plus\
other   (current directory)

. 
. * Simulate user with special folder set in "net set ado" 
. local notplus "C:\ado\not-plus-folder"

. cap rmdir "`notplus'"

. cap mkdir "`notplus'"

. sysdir set  OLDPLACE "`notplus'"

. net set ado OLDPLACE

. 
. * Show current setting
. net query
from    http://www.stata.com
ado     C:\ado\not-plus-folder\
other   (current directory)

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

. 
. * Use adopath()
. ieboilstart, v(14.1) adopath("C:\ado\project-ado",strict) veryquietly

. 
. * Show current setting
. adopath
  [1]  (BASE)      "C:\Program Files\Stata17\ado\base/"
  [2]  (PLUS)      "C:\ado\project-ado/"

. net query
from    http://www.stata.com
ado     C:\ado\not-plus-folder\
other   (current directory)

. 
. * Install iefieldkit
. ssc install iefieldkit
checking iefieldkit consistency and verifying not already installed...
all files already exist and are up to date.

. 
. * command not availible despite just installed.
. iefieldkit
command iefieldkit is unrecognized
r(199);
kbjarkefur commented 1 year ago

All these settings including net set ado do indeed reset after restarting Stata. Here is output after restarting Stata after running the code above.

* Show default setting
. sysdir
   STATA:  C:\Program Files\Stata17\
    BASE:  C:\Program Files\Stata17\ado\base\
    SITE:  C:\Program Files\Stata17\ado\site\
    PLUS:  c:\ado\plus\
PERSONAL:  c:\ado\personal\
OLDPLACE:  c:\ado\

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

. net query
from    http://www.stata.com
ado     c:\ado\plus\
other   (current directory)
kbjarkefur commented 1 year ago

Solution is probable to include net set ado PLUS before these lines:

https://github.com/worldbank/ietoolkit/blob/dfaff6e1f87a625d514c701b9c9b1b7de55028ac/src/ado_files/ieboilstart.ado#L103-L106

I will test when we are done reorganizing the run folder here: https://github.com/worldbank/ietoolkit/pull/336

kbjarkefur commented 1 year ago

I will keep the minor bug label despite this is a breaking bug because the case is rare. Since the bug is possible we should address, but I do not see a reason for a hotfix release.