使用Emacs Tramp连接Dreamhost共享服务器时路径异常求助
I’ve run into this exact issue with TRAMP connecting to Dreamhost shared servers before—super frustrating when you end up in / instead of your home dir! Here are the solutions that worked for me:
Specify your home directory directly in the TRAMP connection string
Dreamhost shared hosting uses/home/your-usernameas your personal home directory. Instead of using the basicssh://your-username@your-dreamhost-server.com, use this full path:ssh://your-username@your-dreamhost-server.com/home/your-usernameTRAMP will land straight in your home directory when you connect.
Set a default path for Dreamhost servers in your Emacs config
To avoid typing the full path every time, add this to your Emacs init file (like~/.emacsor~/.emacs.d/init.el):(add-to-list 'tramp-default-proxies-alist '("\\.dreamhost\\.com$" nil "/home/your-username/"))Now any TRAMP connection to a
.dreamhost.comserver will automatically default to your home directory.Check your local SSH config for conflicts
If you have a~/.ssh/configentry for your Dreamhost server, double-check for settings likeRemoteCommandor customUservalues that might be overriding TRAMP’s default behavior. Make sure those settings don’t force a jump to the root directory.Manually switch directories if you’re already in
/
If you’re stuck in the root directory, useM-x cdin Emacs and enter:/ssh:your-username@your-dreamhost-server.com:/home/your-usernameOr use
C-x C-fto open a file in your home directory—TRAMP will automatically switch to that path.
内容的提问来源于stack exchange,提问作者Micah Cobb

