projectile-find-file-in-directory does not work in TRAMP projects
https://github.com/bbatsov/projectile/blob/a4b447d980b10cbb8d175d64e4305b4504c03d83/projectile.el#L3569
The resolution probably relates to expand-file-name being passed a tramp directory. I will post here any updates I find to fixing it.
Currently it attempts to open the file on the local FS, so /ssh:machine:/blah/blah ==> /blah/blah locally.
projectile-indexing-method 'native solves this, but takes a super long time to index, so this may be a deeper issue with how the alien method returns remote projects' name.
Yeah, so it seems the cached filenames need to be normalized when indexing between alien & native methods for tramp projects. The absolute paths the alien method produces shortcut the TRAMP default-directory. The expand-file-name method returns the name without the tramp default directory when handed an absolute filename.
@codemac Mind putting some PR together to tackle this.
Yeah, so it seems the cached filenames need to be normalized when indexing between alien & native methods for tramp projects.
Which cached filenames? Those in the project cache, right?
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!
Sorry, @bbatsov yes these are the cached project filenames.
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!
I stopped using TRAMP, and only use projectile locally due to other extensions issues with assuming local buffers.
I don't have time to implement this, but I do think this is still an issue for projectile's file cache.
Currently it attempts to open the file on the local FS, so /ssh:machine:/blah/blah ==> /blah/blah locally.
Yes. Alien indexing method returned absolute file paths which in turn failed projectile-find-file in Tramp session for me. Got that working with fix in the way projectile-dir-files-alien create list of files with relative paths instead of absolute paths. And it seams that fixed find-file-in-directory too.
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!
I use TRAMP every day and am entirely unable to use Projectile on any remote project. I'd really like to and don't want this issue to be closed as stale.
I use TRAMP every day and am entirely unable to use Projectile on any remote project. I'd really like to and don't want this issue to be closed as stale.
Got that working with some combination of:
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)(setq-default projectile-indexing-method 'alien)- create empty .projectile in root of remote project path
I hadn't tried (add-to-list 'tramp-remote-path 'tramp-own-remote-path) before, but it didn't seem to help. I have all three of those in place now, but any time I try to use projectile-find-file or any of its friends, it just prompts me to switch to a project.
Does anyone have any other suggestions? Most of my work is done on remote servers, and I'd really love to use projectile.
@thornjad
I don't know exactly where you're stuck but this works for me.
You can use (setq projectile-indexing-method 'native) along with (setq projectile-enable-caching t)
Occasionally, I have to sync the cache. It is slow only the first time you run projectile-find-files because it needs to index the entire project.
If you're regularly deleting files, this probably won't work for you.
@adithyaov your suggestion doesn't have any effect for me. Nothing has, I just can't get projectile to work with tramp at all.
If it works for me and does not work for you, it's probably because we are using different versions of projectile or emacs. Maybe try again after updating emacs to 27.* and projectile to its latest commit.
My Emacs is built from the master branch (which currently reports as version 28.0.50) and I'm on the latest commit of Projectile already.
However, this has been broken for me for a couple years, so I'm not sure any recent version changes will make a difference.
If nothing works, you can always use sshfs.
TRAMP is significantly more performant than SSHFS, at least for my work; I'd rather have Projectile work properly than change my workflow to suit it
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!
Be gone, stale tag, this is still an issue
FYI, I've stopped using TRAMP regularly, so this isn't so much of an issue for me anymore, but I never did get it working (now on Emacs 29, with the latest Projectile commit as of a couple months ago). Projectile continues to work well locally.
Same problem here (projectile-20220828.1421 on Windows). Changing projectile-indexing-method to native fixes the problem, but besides taking 20x longer to index, I need to use hybrid because without it, projectile doesn't use .gitignore.
Just to add a "what fixed it for me", my projectile projects over TRAMP were showing no files until I uninstalled fd-find on my desktop running emacs. I understand there is a projectile-git-use-fd, which I did not test. The remote server does not have fd installed, and I have no means of installing it there sadly.
Sadly there's no easy way to detect what tools are available remotely, that's why Projectile tries to use remotely whatever it found locally. You can open an issue about this - at the very least we can add something to the docs about this.