gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
16.51k stars 691 forks source link

gleam add with multiple dependencies #3254

Open BrentGruber opened 4 weeks ago

BrentGruber commented 4 weeks ago

When running the gleam add command with multiple dependencies it seems that there is a dependency tracking issue where the dependent packages do not get tracked accordingly, causing an issue when trying to run the project.

example command:

gleam add wisp lustre mist gleam_http gleam_erlang dot_env gleam_json

The above command causes the project to fail when installing dependencies. thanks to some help from @mark on the gleam discord server this was narrowed down to the wisp and dot_env packages and further down to the shared simplifile dependency.

When running the command above it install wisp version 0.1.0, which results in an error stating that wisp does not have the required dependencies

The module `wisp` does not have a `Request` type.

This is because when using multiple packages in the gleam add command (including wisp and dot_env) it ends up installing a much older version of wisp (0.1.0 instead of 0.14.0).

fabjan commented 4 weeks ago

dot_env (at least as of 1.0.0) requires simplifile 2.0.0 or later (but below 3).

All versions of wisp after 0.1.0 require some version of simplifile that is not compatible with 2.0.0.

As such, it looks like resolving to wisp 0.1.0 is not a bug per se, right?

lpil commented 3 weeks ago

Thank you @fabjan ! Great detective work

rawhat commented 2 weeks ago

I definitely don't have anything conclusive, but I tried a number of combinations here. It seems like including gleam_json causes the problem.

I think it attemps to grab gleam_json >= 2.0 or something? There is no wisp version that can support gleam_json of that version. So the version it lands on is v0.1 which I think does not depend on gleam_json at all.

If you omit gleam_json from that list of packages, it seems to install most of the latest versions (just spot-checked, possible that things are still slightly out of date). You can then gleam add gleam_json, which grabs gleam_json v1.0.1.

It's strange because omitting it still pulls down that exact version in the manifest.toml. But including it in the list of packages causes the above issue.

hooper ~/gleams/article_test (No*) δ gleam add wisp lustre mist gleam_http gleam_erlang dot_env gleam_json
  Resolving versions
Downloading packages
 Downloaded 19 packages in 0.03s
      Added wisp v0.1.0
      Added lustre v4.2.6
      Added mist v1.2.0
      Added gleam_http v3.6.0
      Added gleam_erlang v0.25.0
      Added dot_env v1.0.0
      Added gleam_json v2.0.0
hooper ~/gleams/article_test (No*) δ gleam add wisp lustre mist gleam_http gleam_erlang dot_env
  Resolving versions
Downloading packages
 Downloaded 5 packages in 0.00s
      Added wisp v0.15.0
      Added lustre v4.2.6
      Added mist v1.2.0
      Added gleam_http v3.6.0
      Added gleam_erlang v0.25.0
      Added dot_env v1.0.0
hooper ~/gleams/article_test (No*) δ bat manifest.toml | rg gleam_json
  { name = "gleam_json", version = "1.0.1", build_tools = ["gleam"]
  ...
rawhat commented 2 weeks ago

🤔 hmm, this is just wrong, no?

hooper ~/gleams/article_test (No*) δ gleam add wisp gleam_json
  Resolving versions
Downloading packages
 Downloaded 6 packages in 0.01s
      Added wisp v0.3.0
      Added gleam_json v2.0.0

Even the latest wisp requires gleam_json < 2.0.0. Maybe this is a version resolution bug?