ROS installation: no such file or directory
Solution 1
I had the exact same issue. The problem is not due to setup.bash
either ~/.bashrc
but the shell that you are using. It turned out that you may be using a different shell than bash
(i.e., zsh
). When you are executing the setup.bash
of ROS, zsh
interprets the following command (whici is in /opt/ros/kinetic/setup.bash
) differently:
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
It is setting the _CATKIN_SETUP_DIR
to your user directory. That is why you are getting error, cause you using the wrong path:
/home/user/setup.bash
instead of /opt/ros/kinetic/setup.bash
To check whether this is the issue of your problem, you can check the shell that you are using by execute the following in the terminal:
echo $0; echo $SHELL
It may return something like:
zsh
/bin/zsh
To switch from zsh
to bash
, use:
exec bash
Once done this, you can use source without any problem.
And to switch back to your previous shell (assuming that is zsh
), just use:
exec zsh
Solution 2
The file /opt/ros/kinetic/setup.bash
does nothing but loading /opt/ros/kinetic/setup.sh
from the same directory. I might be that you are not running bash
(check which terminal you run), or that WSL has some different behavoiour than expected.
However, your can just alter your append command like so:
echo "source /opt/ros/kinetic/setup.sh" >> ~/.bashrc
or in your case, since the entry exists already in your ~/.bashrc
, edit the line source /opt/ros/kinetic/setup.bash
to source /opt/ros/kinetic/setup.sh
Solution 3
The packages or files were not actually downloaded from the "http://wiki.ros.org/melodic/Installation/Ubuntu". To overcome this error first open terminal
check your directory
pwd
. If your directory is like /home/'Your PC Name' it won't actually work.Change the directory : Type
cd /
Continue the installation process from start which mentioned in "http://wiki.ros.org/melodic/Installation/Ubuntu"
melodic can change to kinetic or other version if you wish
shmpwk
Updated on June 14, 2022Comments
-
shmpwk almost 2 years
According to ros wiki, to set up environment, I typed
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc source ~/.bashrc
The error is
/opt/ros/kinetic/setup.bash:.:8: no such file or directory: /home/pikashun/setup.sh
In
~/.bashrc
file, there is thesource /opt/ros/kinetic/setup.bash
line.I use Ubuntu on WSL. How can I improve?
Thank you!
-
Shubham Agrawal over 2 yearsInstead of sourcing the bash file, try sourcing the zsh file as
source /opt/ros/kinetic/setup.zsh
. -
Alex about 2 yearsI think @ShubhamAgrawal's answer is the right way to go, as it allows you to keep working in zsh.
-