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

Path dependencies module resolution bug #2278

Open
DanielleMaywood opened this issue Jul 20, 2023 · 4 comments · May be fixed by #3398
Open

Path dependencies module resolution bug #2278

DanielleMaywood opened this issue Jul 20, 2023 · 4 comments · May be fixed by #3398
Labels
bug Something isn't working help wanted Contributions encouraged priority:high

Comments

@DanielleMaywood
Copy link
Contributor

Description of behaviour

Given some project foo that has a path dependency bar, if bar adds a dependency baz after foo has already been built, attempting to rebuild foo will fail complaining that module baz cannot be found.

Steps to reproduce

The following steps but as a video

Given the following project setup:

foo/
  gleam.toml
  src/
    foo.gleam
bar/
  gleam.toml
  src/
    bar.gleam
# foo/gleam.toml 

[dependencies]
bar = { path = "../bar" }
// foo/src/foo.gleam

import bar

pub fn main() {
  bar.say_hello()
}
# bar/gleam.toml

[dependencies]
gleam_stdlib = "~> 0.29"
// bar/src/bar.gleam

import gleam/io

pub fn say_hello() {
  io.println("Hello from bar!")
}

If you then take the following commands:

~/foo $ gleam build
~/foo $ cd ../bar
~/bar $ gleam add simplifile

And then update bar/src/bar.gleam like following

// bar/src/bar.gleam

import simplifile
import gleam/io

pub fn say_hello() {
  let assert Ok(_) = simplifile.make_directory("hello-from-bar")

  io.println("Hello from bar!")
}

And then finally attempt to build foo again

~/foo $ gleam build

It will fail with the following error message:

  Compiling gleam_stdlib
  Compiling bar
error: Unknown module
  ┌─ /Users/dan/Repositories/gleam-path-deps-bug/bar/src/bar.gleam:1:8
  │
1 │ import simplifile
  │        ^^^^^^^^^^

No module has been found with the name `simplifile`.
@lpil
Copy link
Member

lpil commented Jul 25, 2023

Thank you

@lpil lpil added bug Something isn't working help wanted Contributions encouraged area:build-tool priority:high and removed area:build-tool labels Jul 25, 2023
@ghost
Copy link

ghost commented Sep 3, 2023

Hi I would like to work on this issue.

@lpil
Copy link
Member

lpil commented Sep 3, 2023

Thank you!

Do you have an idea for how to approach this?

@ghost
Copy link

ghost commented Sep 4, 2023

Not sure yet, but I did reproduce the issue exactly as above and noticed that I could get /foo to build properly by deleting /foo/manifest.toml, waiting for a new manifest to be autogenerated, and running gleam build again.

Looking inside /foo/manifest.toml, the difference i see is that simplifile was added to 'packages':

packages = [
  { name = "bar", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "simplifile"], source = "local", path = "/home/md/work/module_res_bug/bar" },
  { name = "gleam_stdlib", version = "0.30.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "8D8BF3790AA31176B1E1C0B517DD74C86DA8235CF3389EA02043EE4FD82AE3DC" },
  { name = "simplifile", version = "0.1.10", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "263B7C7F4B29263555DEA2D30BA918425A27120CDD1E1352744EAB4D56CE01CE" },
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions encouraged priority:high
Projects
None yet
2 participants