tramp 远程无法找到 process

在远程服务器上我没有 sudo 或者 root 权限, 因此我把包都安装在 ~/bin 下 , 包括 ripgrep, ~/bin 在 ~/.bashrc 中已经被设置到 PATH 中了. 现在我想要访问远程文件后仍然能使用 counsel-rg 或者 consult-ripgrep, 我执行了:

(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'tramp-remote-path "~/bin/")

但这样设置之后, 再访问远程 consult-ripgrep 仍然会提示:

env: 'rg' : No such file or directory

counsel-rg 会提示:

Required program "rg" not found in your path

这可能是什么原因导致的呢? 还是我的配置方法根本不对?

估计是~的问题

关于 tramp-own-remote-path,文档已经写了:

Private Directories are the settings of the $PATH environment,
as given in your ~/.profile.  This entry is represented in
the list by the special value tramp-own-remote-path.

另外 Remote programs (TRAMP 2.5.3.28.2 User Manual)

Note that this works only if your remote /bin/sh shell supports the login argument ‘-l’.

确认完之后,应该需要在 .profile 设定 $PATH,类似

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

可以通过如下命令尝试验证

ssh host '/bin/sh -l -c '\''echo $PATH'\'

奇怪的是我 $PATH.zshenv 中也设置成功了,不是很清楚为啥

3 个赞