projectile icon indicating copy to clipboard operation
projectile copied to clipboard

projectile-find-file-in-directory does not work in TRAMP projects

Open codemac opened this issue 7 years ago • 26 comments

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.

codemac avatar Aug 24 '18 20:08 codemac

Currently it attempts to open the file on the local FS, so /ssh:machine:/blah/blah ==> /blah/blah locally.

codemac avatar Aug 24 '18 20:08 codemac

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.

codemac avatar Aug 24 '18 21:08 codemac

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 avatar Aug 30 '18 16:08 codemac

@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?

bbatsov avatar Sep 20 '18 05:09 bbatsov

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!

stale[bot] avatar May 08 '19 17:05 stale[bot]

Sorry, @bbatsov yes these are the cached project filenames.

codemac avatar May 08 '19 17:05 codemac

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!

stale[bot] avatar Aug 07 '19 01:08 stale[bot]

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.

codemac avatar Aug 07 '19 21:08 codemac

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.

TrunovS avatar Dec 07 '19 12:12 TrunovS

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!

stale[bot] avatar Jun 04 '20 23:06 stale[bot]

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.

thornjad avatar Jul 07 '20 20:07 thornjad

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

TrunovS avatar Jul 21 '20 08:07 TrunovS

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.

thornjad avatar Jul 23 '20 20:07 thornjad

Does anyone have any other suggestions? Most of my work is done on remote servers, and I'd really love to use projectile.

thornjad avatar Oct 08 '20 16:10 thornjad

@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 avatar Dec 09 '20 01:12 adithyaov

@adithyaov your suggestion doesn't have any effect for me. Nothing has, I just can't get projectile to work with tramp at all.

thornjad avatar Jan 29 '21 16:01 thornjad

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.

adithyaov avatar Jan 30 '21 18:01 adithyaov

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.

thornjad avatar Feb 01 '21 16:02 thornjad

If nothing works, you can always use sshfs.

adithyaov avatar Feb 04 '21 11:02 adithyaov

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

thornjad avatar Feb 04 '21 16:02 thornjad

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!

stale[bot] avatar Aug 22 '21 18:08 stale[bot]

Be gone, stale tag, this is still an issue

thornjad avatar Aug 22 '21 19:08 thornjad

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.

thornjad avatar Jan 07 '22 18:01 thornjad

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.

goldfita avatar Oct 10 '22 00:10 goldfita

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.

chy-causer avatar Feb 02 '24 13:02 chy-causer

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.

bbatsov avatar Feb 02 '24 14:02 bbatsov