-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
Fix dependency resolution for path dependencies #3398
base: main
Are you sure you want to change the base?
Conversation
Thank you! Could you expand on what the issue is with the language server in this case? Why is that it continues not to work after this change and what is the path to making it work? |
Of course. Suppose you have this project structure:
The language server watches A solution would be to also watch for changes to But I am also fine with restarting the LSP. I have never seen a language that does this, without also having proper support for monorepos/workspaces. |
Why is a restart required? What happens if the language server is not required? The language server uses the build tool, so doesn't it pick up the changes on the next compilation?
This is not an option, the LS supports monorepos and multiple packages. |
I just tested it with VSCode and Neovim. I have three packages that depend on each other in a chain of Then I add When I open the However, when working in a single package, there is no need to perform a compilation. When I add a package, the LSP picks up the change and works as expected in both Neovim and VSCode. I am not sure how exactly it works, I didn't explore the LSP code fully, but these were my observations. |
That sounds like it does work. The language server doesn't automatically pick up changes, it only does anything when the editor tells it that there is a change and compilation is needed. VS Code tells the LS about changes to If |
Hmm. Yes, it does. I didn't think of testing this. When I edit So, if this is considered "correct behavior" is there anything more needed for this PR to be ready to merge? After rebasing ofcourse. Do we want to test this? And if so, could you give me directions because I didn't see a test infra setup for something like this. Thanks |
Yup, that's the right behaviour! I've just looked at the code and it looks like it is recording dependencies of path dependencies as being direct dependencies of the root package? Unless I'm misreading the code. Instead you'll need to determine if any path dependencies have changes their requirements. |
The code should be doing this: I simply collect all the dependencies from all path deps recursively, and check if all those are present in the manifest. That's it. It doesn't store it anywhere. It is only used for that one check and then discarded. And because the manifest should contain all dependencies of all dependences recursively, this seemed to be a simple solution to the problem. Please correct me if my assumptions were wrong. |
Could you please explain what problem my approach would cause? Or is it only about making it less "hacky" and making the code clearer? I can't seem to understand why doing this only in the if check (not storing this modified list anywhere) may cause issues. |
It's being added to the manifest in the section that lists the direct dependencies.
The manifest records them all in the Instead you'll need to determine if any path dependencies have changes their requirements. This could be done by storing the mtime and the checksum of their gleam.toml in the build directory. |
I have just ran through my "three package test" again (the one I mentioned earlier) and the packages are being added to the This is the maniest: # This file was generated by Gleam
# You typically do not need to edit this file
packages = [
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_stdlib", version = "0.39.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "2D7DE885A6EA7F1D5015D1698920C9BAF7241102836CE0C3837A4F160128A9C4" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "second", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "third"], source = "local", path = "../second" },
{ name = "third", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], source = "local", path = "../third" },
]
[requirements]
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
second = { path = "../second" } I think this manifest is correct... I wouldn't want to overcomplicate the approach if this minor change is enough. But if you would prefer checking changes in all path deps, i could implement that as well. But I'm wary of proceeding if I don't understand where the issue is here. |
Closes #2278
If a project foo had a path dependency of project bar, and the developer adds a new dependency to bar, foo will become unbuildable, until the manual deletion of the
manifest.toml
file.During dependency change detection, also check recursively all path dependencies. This will observe any new dependencies added to any of the path deps.
The LSP problem:
Also, I am not sure if there is an existing setup for tests, which could test this behavior. (Or even if we want to test it at all)