Skip to content

Provide an entrypoint to programmatically determine if a project does not have its dependencies installed. #4645

@JosiahParry

Description

@JosiahParry

Hello! This seems to be a contentious issue dating back at least 7 years that I can see—so I apologize for rehashing, but it seems to be important. Caveat: I'm not a julia programmer, just someone who likes and wants to support the community if i can :)

Feature request:

Provide an entrypoint to programmatically determine if a project does not have its dependencies installed.

Related:

Use case

We use using Pkg; Pkg.activate("."); Pkg.instantiate() to handle environment restoration for julia in ricochet.

However, it is possible that a project's package environment gets out of sync—for example if the depot path is deleted or cleared. It would be nice to be able to have a programmatic way to check this.

For example, after instantiating from a Manifest.toml we get:

# After Pkg.instantiate()
Status `~/github/rust/rico-root/ricochet/content/01KMR6103Z8EA87EW2MPPY9JHH/bundle-01KMR61043W7MFRMMH2FR8MG8H/Project.toml`
⌃ [a93c6f00] DataFrames v1.7.0
  [8b842266] PalmerPenguins v0.1.4
⌃ [f0413319] Tidier v1.5.1
Info Packages marked with ⌃ have new versions available and may be upgradable.

This shows things are installed but some have an update—in our case we want to ignore the upgradable messages as those aren't in the Manifest.toml.

After clearing depot the project then returns

  [1b08a953] Dash v1.5.0
 ⌃ [a93c6f00] DataFrames v1.7.0
 ⌃ [cd3eb016] HTTP v1.10.15
 ⌃ [7073ff75] IJulia v1.26.0
   [8b842266] PalmerPenguins v0.1.4
⌃ [f0f68f2c] PlotlyJS v0.18.16
⌃ [f0413319] Tidier v1.4.0
Info Packages marked with  are not downloaded, use `instantiate` to download
Info Packages marked with ⌃ have new versions available and may be upgradable.

This is helpful visually, but this information cannot be captured with ease without capturing the output as a string and grepping. I don't think Pkg.dependencies() resolves the issue either as it doesn't tell us the status of each of the dependencies.

Other ecosystems

In R we can use renv::status() which invisibly returns a list we can check while also providing informative messages.

x <- renv::status()
There are no packages installed in the project library.
Use `renv::restore()` to install the packages defined in lockfile.

x
#> $library
#> $library$Packages
#>  named list()
#> 
#> 
#>  $lockfile
#>  $lockfile$Packages
#> named list()
#> $synchronized
#>  [1] FALSE

when using uv with Python we can run uv sync --frozen --check this is most analogous to Pkg.status(). There's primary two differences I can see:

  • uv is a cli tool
  • uv returns an exit code 1

Since Pkg.status() is not a cli tool returning a status of 1 doesn't necessarily make sense.

flask-hello ⚡ uv sync --frozen --check
Using CPython 3.12.12
Would create project environment at: .venv
Would download 7 packages
Would install 7 packages
 + blinker==1.9.0
 + click==8.3.1
 + flask==3.1.3
 + itsdangerous==2.2.0
 + jinja2==3.1.6
 + markupsafe==3.0.3
 + werkzeug==3.1.6
The environment is outdated; run `uv sync` to update the environment
flask-hello ⚡

Desired solution

An optional argument that returns a dictionary with:

  • synchronized: bool
  • not_downloaded: Vector{string}
  • upgradable: Vector{string}

Question

  • Is there a way to get this type of behavior today? I've tried looking through Pkg.dependencies() but i don't think this tells you the status of the deps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions