Accessing remote tags file with Emacs - emacs

I use Emacs (run natively in OSX) to edit files (mostly python code) on Ubuntu VMs. I run a VM locally, but also access code on EC2. I recently learned about exuberant-ctags and was able to successfully create a tags file on my local VM. The tags file is fairly large (30 MB). I'm accessing the tags file in Emacs using tramp via ssh. My first question is should I expect the access to take a long time? It takes Emacs a few minutes to load the tags file, even though its pulling the file off of a VM running on the same machine.
The second problem I have is that after the tags file is loaded, Emacs (again, running natively in OSX) thinks that the code base is on my local drive, not on the drive of the VM and so gives me a file not found error. So if function X is defined in file Y, how do I get Emacs to figure out that file Y is on the remote machine, not in my local path?
Thanks!

Related

Visual Studio Code with remote db (ssh) shows each file twice

I'm using VS-Code from Windows to remote Linux machine, using SSH, and each file appears twice... once with a relative path to the base project path, and once with a full path (/home/$user/...)
It causes lots of problems, such as opening the same file twice (and then being warned that 'file was changed on disk') or cannot find declarations and stuff.
How can I solve that?

Is it possible for VSCode to execute and debug via SSH, with local source code?

I am struggling to execute my codes on my Linux VM, with all files inside my local Windows machine.
So, I have my source code at for example: D:\myCodes\ and
the files are shared to my Linux VM at /media/sf_codes
I linked all my relevant files at /media/sf_codes/src/ to /opt/myCodes/src/. All other files are irrelevant, and only contains about diagrams, SQL files, etc etc that has nothing to do with the Linux VM. So I only link the src folder into the project folder at /opt/myCodes.
I have tried to use Remote-SSH extension, but it just to won't load all files. It is either load local files, and disables all SSH shell, or it opens a folder at the Linux VM. Which is not necessary because the files are local. And I need to su it under different user to be able to write the files, which complicate things a lot. I was able to do it using Docker or WSL, but their use of HyperV complicate things, and broke many things. So I am back with VirtualBox.
I don't need fancy stuffs like sync or whatever magic they provide, just open SSH shell in terminal, preferably multiple ssh terminals to multiple Linux VMs, and work the files in local folder, and that's it.
I think if they can sync the files, what I need is a basic thing to do, and somehow I missed that. How can I do that in VS Code?

Can I add a remote Python interpreter (via SSH) to a local VSCode environment (i.e. a hybrid local/remote SSH setup)?

I have VSCode set up with the "Remote - SSH" extension, and I am able to run a local VSCode window as the face of a full remote environment. Really cool.
However, I would also like to be able to set up a local VSCode environment which loads files from my local filesystem but runs them on a remote Python interpreter (via an SSH connection).
I am hoping I can run all the regular interactive Python REPL stuff using the remote kernel (e.g. show variables, etc). It seems like I should be able to somehow add a remote kernel and then select it via "Python: Select Interpreter", but I can't figure out how.
In the past I was able to configure such a setup in JupyterLab using the "remote_ikernel" package.
Is this possible in VSCode? I've found tons of documentation on the full remote setup, but haven't located information on this hybrid kind of set up.
I found a related bug report which discusses mixing local and remote filesystems (not interpreters).
I suspect that the same difficulties it describes for filesystems may be similar reasons for why local files can not be easily fed into remote interpreters.
The full thread is here for reference:
https://github.com/microsoft/vscode-remote-release/issues/706
The specific quote:
Having a mixed workspace would require that a workspace extension can be active both locally and remotely. Currently an extension can only be active once, either locally or remotely. So this is currently not possible and we have no plans to support this.
The recommendation is to have separate windows open for the local and remote workspace.
So it sound like this is a feature that is not currently supported.

How does VSCode's Remote Extension open files in my local editor through its internal terminal?

I use VSCode's remote development extension fairly regularly. I can use the terminal in VS Code as if it were on my own machine, and even the code command works correctly. That is, when I'm in a remote VSCode session, I can type code path/to/some/file and it will open another editor tab with that file. The terminal session and the file being opened are on the remote machine to which I've connected.
I have VSCode installed on the remote machine, and the code executable is in my PATH. So my question is, how is this functionality implemented behind the scenes? That is, how does VSCode know that when I type code path/to/some/file it should open that file into another editor tab on my machine instead of trying to fire up VSCode on the remote machine?
Literally seconds after I wrote the question I found the answer.
If I run which code in the terminal, it doesn't resolve to the usual VSCode executable, but instead it resolves to one located at $HOME/.vscode-server/bin/a5d1cc28bb5da32ec67e86cc50f84c67cc690321/bin/code.
If I echo $PATH I can see that $HOME/.config/bin and $HOME/.vscode-server/bin/a5d1cc28bb5da32ec67e86cc50f84c67cc690321/bin has been appended to the beginning of the PATH env var that my bash profile generates.
I assume this means that VSCode is executing bash with a different profile script that
Sources my usual bash profile
Creates the directories above and copies some helper programs into them
Modifies my path to include these directories
I also assume that the injected code executable is communicating with my local instance of VSCode in some way, instructing it to open the file in its editor.

Open remote Server Files in local emacs

I used to be a comfortable emacs user and for close to 10 years I completely got away from using emacs (I know its a shame) but I have a wage memory of setting something in .emacs to open remote files in a server via local emacs.
Just to make the scenario clear:
Login to a remote server (ssh) -> emacs somefileInRemoreServer.file &
File get open using the local version of emacs.
My questions are:
Is this possible?
how can I accomplish this?
I have both mac and ubuntu on mac I use Aquamacs. It would be a great help if I can get instructions on both versions.
I'm not sure whether you want to ssh prior to using emacs or ssh using (in) emacs.
If you want to let emacs do all the work check out the links added by phils, TRAMP mode is the way to go for remote editing IN emacs.
If you want to use ssh to mount a remote filesystem (resulting in "local" editing with emacs) you should check out sshfs (man, wiki).
I think it comes with pretty much any of the current distros (or can be installed easily otherwise). It is a fuse extension which allows to mount a remote directory to a local one without any further requirements on the remote side than ssh.
I do like TRAMP for editing one or two files but using sshfs is great for working on a whole project directory which is placed remotely and which you do not want to sync using another method.