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

Update pkgorigins version field on code changes? #684

Open
IanButterworth opened this issue Jun 9, 2022 · 7 comments
Open

Update pkgorigins version field on code changes? #684

IanButterworth opened this issue Jun 9, 2022 · 7 comments

Comments

@IanButterworth
Copy link
Contributor

With the addition of the version field to pkgorigins and the API to access it, I wondered whether Revise should monitor for package version changes and update appropriately?

If so, are changes to the Project.toml itself tracked by Revise, or would the re-parsing of the TOML need to happen on any code change?

cc. @KristofferC

@IanButterworth IanButterworth changed the title Update pkgorigins.version on code changes? Update pkgorigins version field on code changes? Jun 9, 2022
@timholy
Copy link
Owner

timholy commented Jul 24, 2022

Yes, when an update is successful this would make a lot of sense.

@3f6a
Copy link

3f6a commented Aug 8, 2023

If I'm not mistaken, Revise already loads new package versions whenever an update happens. However, for some reason pkgversion keeps returning the old version. Maybe pkgversion relies on some global variable that gets assigned when a package gets loaded, and is thus not updated after?

Maybe here: https://github.com/JuliaLang/julia/blob/c40ecd3f03ad2f61648a3d5e3a4b831b56891b20/base/loading.jl#L1829

@IanButterworth
Copy link
Contributor Author

Yeah. Should be a simple fix. Just need to update that dict

@cossio
Copy link

cossio commented Aug 8, 2023

You mean Revise should take care of updating this dict when it loads new pkg versions?
Or the logic should go somewhere else?

@IanButterworth
Copy link
Contributor Author

You mean Revise should take care of updating this dict when it loads new pkg versions?

Yeah

@IanButterworth
Copy link
Contributor Author

I couldn't figure out the right place to do it, but it needs something like this done any time the Project.toml changes, which I guess is a file that isn't currently watched?

It also would need the package id (id here) which could be constructed from the Project.toml, but that might not be healthy design?

    origin = get(Base.pkgorigins, id, nothing)
    if origin isa Base.PkgOrigin && !isnothing(origin.path)
        package_root = dirname(dirname(origin.path)) # assumes `path` is src/Foo.jl
        origin.version = Base.get_pkgversion_from_path(package_root)
    else
        @debug "Failed to update package version" id origin
    end

@IanButterworth
Copy link
Contributor Author

Pkg will soon start highlighting when the pkgorigins version entry for a loaded dependency doesn't match the expected manifest version, so this needs fixing, otherwise it could be confusing. JuliaLang/Pkg.jl#4109

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

4 participants