-
-
Notifications
You must be signed in to change notification settings - Fork 577
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
Don't follow symlinks on project root #1387
Comments
This is caused by calling |
For now I'm workarounding it like this: (defun my-dbox-path-advice (dir)
(replace-regexp-in-string "apps/Dropbox" "dbox" dir))
(advice-add #'file-truename :filter-return #'my-dbox-path-advice) Moreover, this is also required for treemacs to work, although I'm not sure whether it's because of the way it queries projectile or because it has the same "truename" behavior itself. |
There's a PR (#566 ) to fix this, seems like this is a recurring problem. |
Is this really necessary? |
It depends on what you prefer: open the same underlying file one or many times. In the first case you need an absolute and unique path (except that emacs defaulted to the already opened file no matter what the alias were, which I don't know and can't test right now). |
The problem with using the truename (resolved symlinks) is that many/most interfaces don't do that. if projectile forces the project root path to be the truename then it doesn't work with these other tools. For example, suppose I have a workspace with truename /real/root/workspace but I have a symlink /work -> /real/root and I always cd to /work/workspace. Then when I run cmake, for example, it will generate compile_commands.json files containing the /work/workspace paths, not the truepath /real/root/workspace. All other tools, such as ccls etc., will be using the symlink path. All these tools stop working properly because they don't agree with projectile about the project root. I'm not sure how to resolve this issue perfectly for all cases. However, I will say this: I think it's most common for people to always use the same way to find their project root. If there's a symlink then they will either always use the symlink or, i guess, never use the symlink. I think it's highly unusual for someone to use both the symlink and non-symlink methods of locating the same root within the same environment. The typical reason for using a symlink in the first place is that you have a particular way that you always want to access your workspaces, but due to partition size issues, or remote mounting issues, or whatever, you cannot use a physical directory in the location where you want it on some particular systems. So you use a symlink to make all the systems look the same. In these situations you want to always use the symlink path. I think that this model (always using the path the user provided even if it's not the true path) is the one that we should optimize the system to support, and other less common usages, if needed at all, should require some special option to enable. |
@madscientist I agree with everything you have said. My first feature request was to use absolute path indeed, not true name at all, but then I accepted some people may prefer to avoid duplicated views (still I don't know if emacs already handles this by focusing a buffer already showing the same file under a different alias) or there might be implementation reasons (say caching) to avoid aliases. So my compromise solution was: ok then, use true name internally but, after resolving the root, map it to one of the user configured paths so both parts are happy. Doesn't seem difficult to achive, just iterating the list of roots and comparing them by truename with the resolved root for some file, then returning the root as configured and not as resolved. |
Yep, I was just trying to bolster your case 😄 I'm trying to put together an Emacs IDE configuration to publish to my co-workers, and this issue with symlinked root directories is basically the last problem I need to solve before I can do that; it's working pretty well for environments that don't use symlinks but fails utterly when they do: LSP support is non-functional. |
Encountered the same problem, need to use the root's symlinks instead of absolute path. |
I have a slightly different use case with a similar undesired outcome. My project root is a real directory (~/projects/foo)
To make matters worse, the directories liked to are also git repositories, which seem to take precedence. I have made an attempt at describing my use case in this StackOverflow question |
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! |
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it. |
This issue still exists and caused these issues seagle0128/doom-modeline#51 and seagle0128/doom-modeline#209 . I think it should not be closed. |
Fix #51 and #209. Root cause: bbatsov/projectile#1387.
I think it's related to e22a775. |
Any updates on this? Has anyone come up with a reasonable workaround? |
Expected behavior
If my project root is a symlink I don't want it to be expanded/followed by projectile. For example, I have a project in dropbox
~/dbox/project
where~/dbox -> ~/home/apps/Dropbox
is a symlink. There is a.projectile
marker there. I've even manually edited the project roots file and added~/dbox/project
. Now when I open a filefile
in the project usingC-c p p
the buffer file name is~/apps/Dropbox/project/file
instead of~/dbox/project/file
. This plays bad with my config which I don't want to depend on the explicit location of the Dropbox folder, I want to keep this fact isolated behind the symlink.Moreover, the project roots file is updated with a redundant
~/apps/Dropbox/project
, even if~/dbox/project
was already there.Actual behavior
Described above.
Steps to reproduce the problem
Described above.
Environment & Version information
Projectile version information
Projectile 20190126.1117
Emacs version
GNU Emacs 26.1.92 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2019-03-09
Operating system
Arch Linux
The text was updated successfully, but these errors were encountered: