#Where to add support for resolving path dependencies

1 messages · Page 1 of 1 (latest)

unkempt vapor
#

I'm having another go at path dependencies, and am trying to figure out how best to feed the local package versions into pubgrub. We have to do this so we don't end up with version miss-matches if a hex dependency also depends on a path dependency. We could either:

  1. Change the package fetcher (bottom of cli/dependencies.rs) to generate "fake" hex packages from the local dependency config. This would be a simple hack and would not require changing hexpm, but there some stuff in the hexpm::Release type (eg. outer_checksum) which I don't know how to generate.

  2. Change the hexpm API so that the Package type is an enum supporting either hex packages or "pinned" local packages with a single release and no checksum. This would mean the code for local dependencies would be split across two projects, but it seems like maybe the right way to do it.

Any input on which of these seems like the right way to go?

dull tapir
#

The first thing to do is to move all the pubgrub using code from the library and into the compiler

#

Then we can make incremental changes

unkempt vapor
#

Ah, ok awsome

dull tapir
#

It doesn't make sense for the Hex library to understand local versions so it's not the place to implement it

unkempt vapor
#

I imagine you would want the resolver in core with traits to implement the actual http fetching implemented in cli? Also do you want pubgrub fully moved to the compiler (mostly/completely) removed from hexpm, or just replicated in the compiler?

dull tapir
#

Can just move it into the compiler and leave the library as is for now

#

I think from gleam_cli we can inject a HTTP send function but maybe that's it

unkempt vapor
#

I have directly ported everything from resolve_versions on down to the core, and the tests are passing. Now these two things are sitting right next to each-other:

pub trait PackageFetcher {
    fn get_dependencies(&self, package: &str) -> Result<Package, Box<dyn StdError>>;
}

struct DependencyProvider<'a> {
    packages: RefCell<HashMap<String, Package>>,
    remote: Box<dyn PackageFetcher>,
    locked: &'a HashMap<String, Version>,
}

I think perhaps we should start by collapsing these into a single PackageCache holding some sort of Box<dyn HttpClient> and providing fetch(&self, handle: Handle) -> Package where handle describes the package name and where to look for it (hex, local path, git repo, ect).

dull tapir
#

Sounds wise

unkempt vapor
#

Apart from ctually linking the files into /build/packages I think this is almost done. Code is here https://github.com/NthTensor/gleam if I don't get back to this for a while. Probably super buggy and broken, I haven't verified much beyond the unit tests.

GitHub

⭐️ A friendly language for building type-safe, scalable systems! - GitHub - NthTensor/gleam: ⭐️ A friendly language for building type-safe, scalable systems!

dull tapir
#

Amazing!!

unkempt vapor
#

Unless I have missed something obvious this should be complete enough to test. I'm about to try it out a bit. Would you prefer a draft PR now or a wait a bit for it testing and completeness (I want to add git deps too).

dull tapir
#

Both are good by me

#

Lets do git and paths in future PRs though!