ROS installation: no such file or directory - bash

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 the source /opt/ros/kinetic/setup.bash line.
I use Ubuntu on WSL.
How can I improve?
Thank you!

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

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

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

Related

WSL hide /mnt/c/Users/

It is possible to view shorter path in my terminal (VS Code & Hyper) with WSL (Ubuntu). On top of the Ubuntu, I have installed zsh. Currently, I am using a git bash and path looks Lukas#Y50-70 ~/Coding but with the Ubuntu, I have something like this lukas#Y50-70 /mnt/c/Users/Lukas/Coding. When I have a project in another 2 folders or so and I have a long branch name it is annoying to have a full row unnecessary info (for me).
Here is a comparison of Ubuntu and git bash:
Thanks
I was able to solve this using Named Directories - by adding this line to your ~/.zshrc file
hash -d c=/mnt/c
you will see '~c/' in your prompt rather than '/mnt/c/' which I think is a lot nicer.
This has a similar effect to setting an alias for the directory but the name is reflected in how your path is displayed.
As an added bonus you can then switch to that directory at any time by typing ~c
Check if the zsh installation guide under WSL can help (from neurogenesis):
Install zsh with sudo apt-get install zsh
bash.exe is the entrypoint to the WSL / linux subsystem. You'll have to modify the windows shortcut to specify bash -c --login or modify ~/.bashrc with exec /bin/zsh to properly load a different shell.
/etc/passwd isn't consulted because it's not a full login process. Be sure to set your SHELL env var as well. See #846 for details.
Fix your umask before you start installing things, otherwise tools like zsh will complain.
Specifically, "group" and "other" permissions will have the same privileges that owner do. This causes zsh's compaudit and compinit to fail (both are related to command completion).
See #352 for details. umask 022 can be added to your ~/.bashrc.
NOTE: This should be done before trying to install zsh plugin managers like antigen (otherwise the directory/file permissions issues from git clones).
You should also do this before installing RVM or rbenv.
I ended up inserting a few lines to the top of my ~/.bashrc, something like the following:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
## Fix missing umask value
umask 022
## Launch Zsh
if [ -t 1 ]; then
cd $HOME
export SHELL=/bin/zsh
exec -cl $SHELL
fi
Issue 846 (mentioned in point 2) includes the comment:
A normal -c zsh symlink opened up in the wrong directory to me, but I managed using this (note the tilde):
C:\Windows\System32\bash.exe ~ -c /bin/zsh
See also "How to Use Zsh (or Another Shell) in Windows 10".
I know this isn't exactly the fix you were hoping for. I was looking to solve the same issue. The prompt was just too long and it was causing some of my commands to wrap to the next line. After seeing the comments on VonC's answer, I'm deciding to keep my next-best solution.
What I did in my ~/.bashrc file is this:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u#\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\n\$ '
fi
I added a \n right before the \$
So when I'm at my Windows home folder, it looks like this
ryan#DESKTOP-RSKAA4F:/mnt/c/Users/ryank
$
And I start typing my commands after the $. It takes up more vertical space, but at least I don't have to maximize my terminal window just to avoid text wrap.
It appears to me that just running 'cd' after starting the terminal session, re-bases the prompt to the normal '/home/(user)'
there should be no need for installing zsh or anything else. It works for me anyway.
also when starting the session at the root folder from windows, seems to do the trick.
I keep my sessions under
C:\vms
sample:
cd -d C:\vms\minikube\ubu_jenkinsX\rootfs
C:\vms\minikube\ubu_jenkinsX\rootfs>wsl -d ubu_jenkinsX
Yours may be under your userprofile in local data. Search for the rootfs folder
The reason your WSL prompt shows such a long path is because you're not actually in your home directory. You see, WSL has its own virtual filesystem separate from Windows, and Windows paths (like your C:\Users\Lukas\...) are stored under /mnt/c/Users/Lukas/.... Your WSL home directory would be /home/Lukas (since your WSL username is capitalized), but of course, that's not where your project is.
The fish shell has a prompt_pwd function that shortens a path to something like this:
0 ---- /m/c/U/L/Documents cd Something
0 ---- /m/c/U/L/D/Something prompt_pwd
/m/c/U/L/D/Something
Is that something you're interested in? You could port the function to Bash, or just switch to Fish, or just display the current directory name instead of path.

.bashrc not sourced on Intellij IDEA's terminal

I have some aliased defined on my .bashrc that I'd like to use on my Intellij IDEA's terminal. Why is .bashrc not sourced?
.bashrc is only loaded when Bash is running in "interactive" mode. For some reason, IntelliJ defaults to running Bash in non-interactive mode, but this is easy to change. Open the IntelliJ Settings window, then open "Tools -> Terminal", and add -i to the Shell path.
(Note that in this screenshot, I have also changed the default shell, because I'm on a Mac, which makes it difficult to update /bin/bash. Unless you have installed a different version of Bash, do not blindly copy this change!)
Had the same issue with IntelliJ.
Solved this by setting the value /bin/bash --login in setting->Tools->Terminal->Shell path.
/bin/bash --login forces the bash to read the ~/.bash_profile.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/205437150-Terminal-not-sourcing-bash-profile?page=1#community_comment_360000167679
In your home directory, add theses lines to .profile (create the file if it does not exist), in order to source .bashrc:
if [ "$SHELL" = "/bin/bash" ]; then
. ~/.bashrc
fi
For me, changing the line
Exec="/opt/idea-IU-183.4284.148/bin/idea.sh" %f
to
Exec=bash -ic "/opt/idea-IU-183.4284.148/bin/idea.sh" %f
worked. We exploit the hack that the interactive shell loads .bashrc :)
On Mac OSX Catalina, "/bin/bash" and ~/.zprofile worked for me:
Update:
Apple has changed the default shell to zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile.
My settings are in ~/.bash_profile . I solved it using:
echo "source ~/.bash_profile" >> .profile
sudo echo ". ~/.bashrc" >> /etc/bash.bashrc
Because > operator doesn't pass the sudo permissions to the write process.
I did this :
echo ". ~/.bashrc" | sudo tee /etc/bash.bashrc
I noticed that .bashrc isn't sourced only when I first install IntelliJ and run it directly via the idea.sh script in bin/.
Once I create the desktop entry via Tools -> Create Desktop Entry... and start it from the Ubuntu dash, .bashrc is sourced properly.
If you have recently moved to zsh from bash then go to ~/.zshrc file and update $PATH variable there:
Default value in .zshrc:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
Change to same PATH variable set in .bashrc and uncomment it
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:<my-bash-paths>:$PATH
None of these answers worked for me. What did work is
sudo nano /etc/environment
...then manually adding my export and alias commands here to make them system wide.
But be careful, do NOT mess up the PATH or you'll have trouble logging back in to your desktop environment, or many other issues.
I had this problem because the default shell had been changed to zsh.
I echoed the shell name with echo $SHELL to see this (thanks How to get default shell).
Then I changed it back to /bin/bash with this command: chsh -s /bin/bash (thanks https://apple.stackexchange.com/a/100476/176809).
Create a bash script with the content;
echo "source ~/.bash_profile" >> .profile
Then in Intellij go to preferences/tools/Startup Tasks;
create a run configuration that runs your bash script and you're good to go.
I just restarted my MAC and it picked up the new stuff.
For me at least, the only thing that works was to put this in the Shell path variable inside of Tools > Terminal :
/bin/bash --rcfile ~/.bashrc

Bash alias doesn't work in cygwin

Can someone please explain to me how to set up bash aliases? I am using cygwin on windows 8.
I added alias my_first_alias='git status' at the end of /.bashrc file. Typing my_first_alias into cygwin results in -bash: my_first_alias: command not found.
Trying to restart cygwin, running . .bashrc doesn't help with that.
The syntax of your alias command is correct and should be working as long as the alias command is actually being executed. It sounds like your .bashrc file is not being loaded when you start your bash shell. Make sure you have the following in your ~/.bash_profile file:
[[ -s ~/.bashrc ]] && source ~/.bashrc
Also make sure that the location of .bashrc and .bash_profile are in your home directory. Above you have referenced /.bashrc. I doubt "/" is your home directory. You can determine the location of your home directory from the shell by entering the command:
cd; pwd

~/.profile, ~/.bashrc, and ~/.bash_profile not running on new terminal start up

I am trying to create a permanent alias for my terminal. I put the alias in my ~/.profile, ~/.bashrc, and ~/.bash_profile files, previously empty. When I start a new terminal, bash does not recognize the alias, but if I source any of them, it does. Why are these not getting run when I open a terminal? I am on OSX.
Newer MacOS versions use zsh as the default shell for both Terminal and iTerm2. Run echo $SHELL to confirm if this is the case for you.
Zsh looks for a .zshrc file upon shell startup, so to continue using zsh while sourcing the contents of your bash profile, you can run the following:
echo "source ~/.bash_profile" >> ~/.zshrc
Open a new terminal window for the changes to take effect.
Two things need to happen here when using iTerm to get the loading of dotfiles to work.
First you should add the following to your .bash_profile
[[ -s ~/.bashrc ]] && source ~/.bashrc
Secondly you will need to ensure that in iTerm preferences your terminal is set to launch a login shell.
Hope this helps!
Using the default mac terminal, what worked for me was to add a command to run on start up to source my .bash_profile.
Preferences > Profile > Startup > Add command 'source ~/.bash_profile'
Mac terminal preferences window screenshot
Might be considered to be a bit hacky, but it does the trick.
Adding source ~/.profile to my .bash_profile worked for me.
As of High Sierra, both Terminal and iTerm want to load ~/.profile first. So I suggest you put one line in your .profile to make your Mac work like other Unixes:
source ~/.bash_profile
By editing this one file, you won't have to search through the menus of multiple apps to override Apple's bizarre behavior in each.
As of Catalina the default shell is now zsh. You can change it back to bash with chsh -s /bin/bash and that should load your .profile or .bash_profile
Why are your shell's initialization files not loading?
As with most things, It Depends ™
I recently experienced the same phenomenon and went through the following exercise to resolve it:
I use iTerm. iTerm runs a login shell by default. Verify in iTerm Preferences > General > Command > (*) Login Shell
Therefore, I know that ~/.bash_profile will always be called.
Knowing that, I put the following in my ~/.bash_profile file:
for file in ~/.{bashrc,bash_exports,bash_aliases,bash_functions}; do
[ -r "$file" ] && source "$file"
done
unset file
Notice that I use separate files for .bashrc, .bash_exports, etc. It keeps things separate and simple.
Note also that /etc/profile is loaded first, but since I have never used that system wide init file, I knew that that was not my problem. For details check out $ man bash
So, I started with my ~/.bash_profile file.
I found that when I installed Canopy Express that it's installer replaced the contents of my ~/.bash_profile file with the following content:
# Added by Canopy installer on 2017-04-19
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make the bash prompt show that Canopy is active, otherwise 1
alias activate_canopy="source '/Users/lex/dev/python/User/bin/activate'"
# VIRTUAL_ENV_DISABLE_PROMPT=1 source '/Users/lex/dev/python/User/bin/activate'
p.s. Canopy is an excellent, free python IDE, that I highly recommend.
Fortunately, I backup my ~/.bash* files so restoring that was easy and quickly fixed my issue.
My advice would be to understand the order of calls to your initialization files and start with the first one and work your way through them until you find the problem.
Oh, and you may want to verify which shell you are using (I use bash):
~ $ echo $SHELL
/usr/local/bin/bash
I am guessing you may use another shell, such as bash, tcsh, sh, zsh etc.
Put source .bash_profile into your appropriate 'bashrc' file will make the auto loading recovered, i.e.
.login for tcsh, .bash_profile for bash, .zshrc for zsh
My issue was solved by unchecking Preferences > General > tmux >
Use "tmux" profile rather than profile of the connecting session
Most likely, you need to create the files yourself as they appear not to exist by default. You should give them execute permission to make them run.
~ % sudo chmod 700 ~/.bash_profile
Also, you should check the ownership of the files. They should belong to current user rather than root. Otherwise, you will get permission denied error.
~ % ls -a -l
~ % sudo chown <user_name> ~/.bash_profile
Finally, please note that bash looks in your home directory for .bash_profile, .bash_login, and .profile in order. Bash will stop looking if the first is found.
This means if you have both .bash_profile and .profile files, the .profile will not run.
For more information
Hope this would help you.
Little late to the party but it seems that the file .zprofile is the equivalent to that of .bash_profile when loading zsh. I used this instead to execute a few commands on startup. Of course this only valid for a specific iTerm setup with zsh.
https://zsh.sourceforge.io/Intro/intro_3.html

Cygwin shell doesn't execute .bashrc

After start the cygwin shell, it just locate in a wrong home dir:
xfire#codingme.com ~
$ pwd
/cygdrive/c/Users/xfire
But it used to be /home/xfire
xfire#codingme.com /etc
$ cat passwd | grep xfire
xfire:unused:22773:10513:U-CORP\xfire,S-1-5-21-527237240-725345543-682003330-12773:/home/xfire:/bin/bash
And the .bashrc in the /home/xfire was not executed, even I copy it to the /cygdrive/c/Users/xfire, it also doesn't work!
On cygwin, I add this to my ~/.bash_profile:
. ~/.bashrc
Some program add an "HOME" environment in windows registry and set the value to "C:\Users\xfire", that's why cygwin take that directory as the home. cygwin.com/faq-nochunks.html
On my version of cygwin I found that only ~/.profile was being execueted so added
if [ -e "${HOME}/.bash_profile" ]; then
source "${HOME}/.bash_profile"
fi
to the .profile file. My .bash_profile file contains another test for .bashrc and executes that from inside there. I also added the following two lines to my .bashrc file.
export BASH_ENV="${HOME}/.profile"
export ENV="${HOME}/.profile"
The first of these ensures that .profile gets executed in non-interactive terminals and the second ensures it gets executed in POSIX terminals. I found a very useful explanation of what get run and when in the Bash Reference Manual.
In your case it wouldn't help as you have an issue with the value of your HOME environment variable but this page comes up quite high on the list when searching for this issue.
You can also also set BASH_ENV variable, e.g., BASH_ENV='C:\DOCUME~1\dwyttenb\.bashrc'
~/.bash_profile is executed before the initial command prompt is returned to the user. After that, every time a new shell is opened, ~/.bashrc is executed.
Adding . ~/.bashrc at end of ~/.bash_profile has resolved the problem.
Now you can check existing aliases using alias command.
Find more details on github.

Resources