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

-require- stumbles when the same program has different versions on different Stata repositories #1

Open
meadover opened this issue Apr 14, 2024 · 2 comments

Comments

@meadover
Copy link

Thanks for updating and maintaining -require-. I am attempting to use it with my students. We ran into a problem which may be more general and might be at least partially solvable.

Nick Cox has just published an updated version of his useful utility -distinct- in the SJ-23-4. My students and I have been using his 2012 version which is on SCC. I would like to type something like:

require distinct>= 1.4.3, install from("http://www.stata-journal.com/software/sj23-4")

Issues: Depending on specified options, -require- will

  • (a) erase the old version without replacing it with the new version (lines 221-240 of attached SMCL file, or
  • (b) replace the old version with the new version, but exit with an error message that it was unable to update the program (lines 249-301).
  • (c) Furthermore, if we run -require- again after its successful install of the new version, it does not recognize its success and exits with an error saying: require: package "dm0042_5" not found in adopath (lines 304-314) of the SMCL..

test_require.do.txt
test_require_nmbrd.smcl.txt

(Remove the extension -txt- to open the above files in Stata.)

Of course, Nick will probably replace his existing SSC version with his updated programs eventually. So to see these potential issues with require, I have captured it in the SMCL file. I imagine it could occur frequently for programs whose package names are different from the program name, such as all those published by the Stata Journal.

Mead

@sergiocorreia
Copy link
Owner

Hi Mead,

Thanks for the very detailed issue!

What you found touches on two current limitations of require:

  1. Poor support for SJ packages

In particular, see these two lines:

https://github.com/sergiocorreia/stata-require/blob/main/src/require.ado#L308
https://github.com/sergiocorreia/stata-require/blob/main/src/require.ado#L472

The problem is that require has no way of knowing that dm0042_5 and distinct are equivalent:

  • When you ask for the dm0042_5 package, it seems several ado files listed in the .pkg (distinct.ado, distinctgen.ado) and has no way of figuring out which one to use to extract version numbers.
  • In the opposite direction, when you ask for distinct using the SJ repository, it doesn't see such package as the file is named dm0042_5.pkg.

It shouldn't be too difficult to build a mapping between package names and their SJ versions, but this mapping will get obsolete frequently (every time an SJ package is updated). Thus, I'm not sure of the best approach here

  1. Uninstall as a condition for installing

Currently, require only reads files locally, so it cannot tell whether install will be successful in providing the required version number until it installs it (which requires uninstalling existing versions).

That said, we should be able to tweak require into reading the version from the online copy of the files, and we should be able to add this into a 1.4.1 release in the short term.

  1. Beyond require

A key limitation of require is that we don't have a list of all the available version numbers. But we've done some progress on this front using Lars Vilhubers' SSC mirror, so we should be able to get a list of every version from the last ~2 years or so (which wouldn't be part of require, and will probably be just a .dta online updated daily). If we do this it might provide another way of also fixing problem #1

Cheers,
S

@meadover
Copy link
Author

meadover commented Apr 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants