bbatsov / projectile

Project Interaction Library for Emacs
https://docs.projectile.mx
GNU General Public License v3.0
4k stars 583 forks source link

Wrong project root inferred in a nested project which is inside a bigger project (two different languages). #1622

Open dimitarvp opened 3 years ago

dimitarvp commented 3 years ago

Expected behavior

I am using Spacemacs (and thus projectile) and LSP.

I have an Elixir project which uses the rustler library which generates a Rust project inside the Elixir's project native/ sub-directory. I did touch ~/code/elixir-project/native/rust-project/.projectile to provide a hint that this is a project nested inside another project. Then I opened a Rust file, say, ~/code/elixir-project/native/rust-project/src/lib.rs and then rust-analyzer complains that it cannot find any projects inside ~/code/elixir-project.

Actual behavior

I expect projectile to infer that the current project it's operating in is ~/code/elixir-project/native/rust-project.

I also tried explicitly setting the project path but that did not help.

Steps to reproduce the problem

Environment & Version information

Projectile version information

Projectile version: 20200517.1330

Emacs version

GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
 of 2020-08-12

Operating system

macOS Big Sur 11.0.1

Questions

bbatsov commented 3 years ago

Yeah, nested projects are supported, but you might have to tweak the project resolution behaviour, as outlined here https://docs.projectile.mx/projectile/projects.html#customizing-project-detection Can you tell me what exactly gets detected as the project root in your case? (in the sense of which of the default functions returns a root first)

dimitarvp commented 3 years ago

I am not sure how to answer, not an Emacs expert by any stretch. Does the link you provided give me functions to run queries with which I can answer you? If not, can you tell me what to run in order to provide the info you asked for?

caleb commented 3 years ago

I am also running into this issue (with Emacs, Clojure and LSP), but adding a .projectile file to my sub-project fixed my issue.

Does projectile require a .git (or other SCM) folder? I added a .git directory to my subproject (just empty) and it also worked.

It's also possible that this is an LSP bug and that LSP looks for SCM folders first. For my case, adding an empty .projectile file helped though.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

xeruf commented 1 year ago

Curious, I thought projectile would also consider projectile-known-projects in its search, so I expected it to work without any markers if I just added the project into there. Well, maybe I can customize it accordingly...

sbwcwso commented 1 year ago

I am also running into this issue (with Emacs, Clojure and LSP), but adding a .projectile file to my sub-project fixed my issue.

Does projectile require a .git (or other SCM) folder? I added a .git directory to my subproject (just empty) and it also worked.

It's also possible that this is an LSP bug and that LSP looks for SCM folders first. For my case, adding an empty .projectile file helped though.

I add a .git directory in my subfolder, and everything works fine. Thank you very much.