每次打开 Ubuntu 终端时,Bash 均提示没有该文件或目录

每次打开 Ubuntu 终端时,Bash 均提示没有该文件或目录

我是 Ubuntu 新手。我试图添加:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

然后我重新加载了 .bashrc :

source ~/.bashrc

现在我被这个问题困住了。每次我启动终端时,我首先都会得到这个:

截图#1

bash: /catkin_ws/devel/setup.bash: No such file or directory
bash: /home/ros/Home/catkin_ws/devel/setup.bash: No such file or directory

编辑:cat ~/.bashrc我得到以下内容(文件的最后一行):

else 
    if [ -f "/home/ros/anaconda3/etc/profile.d/conda.sh" ]; then 
        ."/home/ros/anaconda3/etc/profile.d/conda.sh"
    else 
        export PATH="/home/ros/anaconda3/bin:$PATH" 
    fi
fi
unset __conda_setup 
# <<< conda initialize <<<

source /opt/ros/noetic/setup.bash 
source /catkin_ws/devel/setup.bash 
source ~/catkin_ws/devel/setup.bash 
source ~/catkin_ws/devel/setup.bash 
source ~/catkin_ws/devel/setup.bash 
source ~/Home/catkin_ws/devel/setup.bash 
source ~/catkin_ws/devel/setup.bash 
source ~/catkin_ws/devel/setup.bash 
source ~/catkin_ws/devel/setup.bash 

ls ~/catkin_ws/devel给出:

cmake.lock  local_setup.bash  setup.bash      setup.zsh
env.sh      local_setup.sh    setup.sh        share
lib         local_setup.zsh   _setup_util.py

在此处输入图片描述

答案1

好的,看一下你的结尾.bashrc,你能看到问题吗?

看起来您尝试执行该命令echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc多次,但其中一些命令包含错误。

您需要做的是编辑您的~/.bashrc文件,例如使用 nano:

nano ~/.bashrc

现在,删除末尾(之后)所有不需要的行# <<< conda initialize <<<。我假设您还需要文件/opt/ros/noetic/setup.bash,因此保留以下几行:

source /opt/ros/noetic/setup.bash 
source ~/catkin_ws/devel/setup.bash 

相关内容