I'm using Aquamacs and started the emacs server with M-x server-start. My emacsclient connects just fine. However, when I start another ssh session (on the same pc) it cannot locate my socket-name / server file. It's not in ~/.emacs.d/server/server where I would expect it.
How can I find out which server-file / socket-name the emacs server is currently using?
This is my working configuration:
.emacs
(setq server-socket-dir "~/.emacs.d/server")
(server-start)
em.sh
location="/`whoami`#`hostname`:$(readlink -f $1)"
ssh <YOU#LOCAL-WORKSTATION> emacsclient -n -s '~/.emacs.d/server/server' $location
The variable server-socket-dir (atleast on GNU Emacs) is what holds the location of the socket. The socket file in my case is simply called server.
It's in $TMPDIR/emacsXXX/server where XXX is a number that depends on the version of Aquamacs you're running
This should also fix your problem without needing to manually delete the file.
M-x server-force-delete
Related
I want to use a ssh config file that is not in
~/.ssh/config.
When I use the command line
sh -F my_ssh_config
it works.
Now I want to do the same from Emacs dired (tramp).
Whatever I try it hangs on connecting to my vagrant VM .
What I am trying to do :
I have multiple vagrant project directories, each with its own ssh
private key, some of these are discarded/temporary
I like to
browse my VM folders using Emacs dired
I don't want to use my
~/.ssh/config file - it will get cluttered with these ssh connections
Attempted tweak (got "process died" from Tramp)
ELISP> ( tramp-get-completion-function "ssh")
((tramp-parse-connection-properties "ssh")
(tramp-parse-shosts "~/.ssh/known_hosts")
(tramp-parse-sconfig "/path/to/my_ssh_config_file"))
Also "my_ssh_config_file" functions correctly when used in the shell command "ssh -f my_ssh_config_file" - and gets into my vagrant box.
Tramp does not support alternative config files. Connection arguments are defined in tramp-methods. Check this variable, and double an entry (for example the "ssh" entry) to "myssh" with the arguments you need. However, be careful, because Tramp has several assumptions on the arguments.
I have code on a compute node of a cluster. I can't ssh directly to the compute node so I first set up an ssh tunnel with
ssh -f cluster.master.node -L 2222:cluster.compute.node:22 -N.
Next I visit the file with
C-x C-f /ssh:user#localhost#2222/path/to/blah.c.
Finally I do
M-x gdb.
In emacs 23 I would do
Run gdb (like this) gdb --annotate=3/ssh:localhost#2222:/path/to/program
but documentation for the gdb function in emacs 24 says "The command-line
options should include -i=mi to use gdb's MI text interface. Note that the old "--annotate" option is no longer supported."
Running
gdb (like this) gdb --i=mi /ssh:loalhost#2222:/path/to/program
seems to work, but when I try to run the program I get "Starting program: /misc/home/joey/git/proteus/proteus /dev/pts/5: No such file or directory." The problems seems to be with the non-existent /misc/ directory prepended to the path of the executable. Even when I do a cd to /home/joey/git/proteus/ the response is "Working directory /home/joey/git/proteus (canonically /misc/home/joey/git/proteus)."
Can I remotely debug my program in Emacs 24 or should I go back to 23?
Try M-x gud-gdb RET: it will give you the old Emacs-22 behavior.
I tried to open a remote file via Emacs via Tramp.
(require 'tramp)
(setq tramp-default-method "ssh")
I get a message from Emacs
Tramp: Waiting for prompts from remote shell
Emacs hung and did not respond to any action after that
Emacs was installed on Windows; the remote file was on a Linux machine.
If the account you're connecting to uses some weird fancy shell prompt, then there is a good chance that this is what makes tramp trip.
Log in as root, then enter
PS1="> "
(that's a normal, standard shell (ZSH, BASH, younameit) prompt, one that tramp will understand)
then switch to the user account, and launch emacs -q (to make sure that your .emacs is not causing this mess) and try to C-x C-f /sudo:root#localhost:/etc/hosts and see what's what.
You can (not recommended) also customize the regexp that defines what tramp expects :
M-x customize-variable RET tramp-terminal-prompt-regexp
My approach :
Make sure the variable tramp-terminal-type is set to "dumb"
M-x customize-variable RET tramp-terminal-type
Test that in your .*shrc and serve the correct prompt :
case "$TERM" in
"dumb")
PS1="> "
;;
xterm*|rxvt*|eterm*|screen*)
PS1="my fancy multi-line \n prompt > "
;;
*)
PS1="> "
;;
esac
Your Windows ssh client is the key here, and the 'ssh' Tramp method is almost certainly wrong.
If you're using Cygwin, then you need to use the 'sshx' method, and you probably need to use ssh-agent to handle authentication. Details are here:
Using tramp with EmacsW32 and cygwin, possible?
I imagine the same applies to any stand-alone ssh client which does not require a full Cygwin installation, but does use the Cygwin DLLs. (I mention this, because I'm pretty sure I remember seeing such a thing.)
If you're using PuTTY then you want the 'plink' method, as Alex Ott pointed out. If the Wiki doesn't suffice, a search here will probably turn up solutions for configuring that approach.
Other alternatives I can suggest are:
Use the Cygwin-native Emacs. That will be slower than NTEmacs, but Tramp seems to work well with the 'ssh' method, and password-prompting works as well.
Host a Linux VM on your Windows box, and run Emacs on that. That's a fairly large hoop to jump through, but it's my preferred way of using Tramp when working in Windows.
Well, this is a defect of tramp.
The real solution is to prevent loading .bashrc when tramp is used. (because now it is PS1, but it can be PATH, or any other thing that your .bashrc will do that will displease tramp...).
This can be done by asking ssh to set an environment variable, and testing it in .bashrc:
Add this to ~/.emacs:
(require 'tramp-sh nil t)
(setf tramp-ssh-controlmaster-options (concat "-o SendEnv TRAMP=yes " tramp-ssh-controlmaster-options))
and that at the beginning of ~/.bashrc:
if [ ! -z ${TRAMP-x} ] ; then
return
fi
Another default of tramp is that it doesn't have a variable to pass random arguments to the ssh command, we have to piggy-back on tramp-ssh-controlmaster-options.
Had you checked Emacs wiki for solution? ssh is in PATH? It's also recommended to use plink on MS Windows - see section "Inline methods" in Tramp documentation
If the problem is your fancy custom prompt in the remote shell, an easy workaround is to add to your .bashrc or equivalent:
if [[ $TERM == "dumb" ]]; then
export PS1="$ "
fi
After you define your PS1.
Note: the credit goes to ChasingLogic as this is their suggestion in this thread.
By the way -- if You need tramp to sudo -- You can actually sudo without tramp using sudoedit.
Currently I'm using this bash function:
erf () { SUDO_EDITOR="emacsclient -a emacs" sudoedit $#; }
I use an emacs daemon to preserve my emacs session even if I have to reboot the machine that I run my X server on or if I want to access the same session from a different machine. This works very well but when restoring a session I'd quite like to just run "emacsclient --create-frame --no-wait" to connect to the daemon without opening a new file. It won't let me get away without specifying a filename.
I've tried using --eval to execute a function rather than open a file but the window just goes away when the evaluation is complete.
(Emacs 23.1 via backports on Debian GNU/Linux 5.0.)
From the help provided by emacsclient, you have a few options. First, is the one mentioned already which is emacsclient -c. That will try to create a frame associated with the emacs daemon. The advantage to this is that if DISPLAY is not set, then it will open emacs in the terminal.
Which brings us to the next best option (especially if you are logging in remotely): emacsclient -t which forces emacs to open up in terminal mode even if DISPLAY is set.
Also keep in mind that you can set the display from the command-line as well. I use this often when logging in remotely from VNC. The full command would be emacsclient -d DISPLAY -c
emacsclient -c works for me.
emacsclient -n -e "(make-frame)"
The -n flag means that the emacsclient doesn't wait, and the emacs instance doesn't destroy the frame.
If you are using emacs from the command line, you might also want to consider emacsclient -t
I'm using emacs 23.1 on Windows XP with the following configuration
(require 'tramp)
(setq tramp-default-method "ftp")
I can open/save remote files. Find-file auto-completion with TAB works as well. But I cannot open a remote directory, it shows an empty buffer with a directory name on the top.
Here are log messages
ls -lhA d:/temp/ange-ftp2876pvQ
200 PORT command successful.
150 Opening data connection for /bin/ls.
226 Transfer complete.
quote mdtm /soft/mysrv/jboss-4.2.3.GA/bin/
550 /soft/mysrv/jboss-4.2.3.GA/bin/: not a plain file.
quote mdtm /soft/mysrv/jboss-4.2.3.GA/bin/
550 /soft/mysrv/jboss-4.2.3.GA/bin/: not a plain file.
And I cannot dired-do-copy several marked files to the remote directory. It copies only the first file and says "No file on this line". Should I switch to ssh tramp to resolve these problems?
What are other advantages of changing to ssh if I don't care about security and clear text passwords?
UPDATE: I changed
(setq tramp-default-method "pscp")
and it works now.
I can't tell you how well the ftp method works in general as I usually work with scp or ssh. Advice like "If the ftp method doesn't work, use it" is probably not what you are looking for.
However, you may want to have a look at the tramp-default-method-alist variable that lets you specify which method to use based upon the remote user and the remote host.
Yes, it was necessary to change tramp-default-method
(setq tramp-default-method "pscp")
Now it works correctly on the servers where ssh is installed.