# Not a Valid Identifier

I am following the tutorial found on the book Learning ROS by Martinez page 40. When creating a new workspace, after adding a folder and trying to add this path to ROS_PACKAGE_PATH I keep getting the following:

bash: export: ROS_PACKAGE_PATH~/dev/rosbook:/opt/ros/kinetic/share:/opt/ros/kinetic/stacks': not a valid identifier


These are the commands:

clare@clare-VirtualBox:~$echo "export ROS_PACKAGE_PATH"~/dev/rosbook:${ROS_PACKAGE_PATH} >> ~/.bashrc
clare@clare-VirtualBox:~\$ . ~/.bashrc

edit retag close merge delete

that line you're trying to run, is from the book Aaron wrote right? I got the same problem. looks like the book is pretty old and not gonna work for me.

( 2016-09-25 18:21:09 -0600 )edit

Sort by » oldest newest most voted

First: don't do what you are trying to do. It is unnecessary to manually edit the ROS_PACKAGE_PATH. It will automatically be updated to include the proper paths whenever you source your target workspace (which in your case I'm guessing is located at ~/dev/rosbook.

After building your workspace, do a source ~/dev/rosbook/devel/setup.bash. That will setup the correct paths.

Second: if you really want to do this, notice that you are missing a = (equals) between ROS_PACKAGE_PATH and ~/dev/rosbook. That most likely leads bash to interpret the entire line as the name of the environment variable that you are trying to set. It then notices that that name includes some illegal characters (ie: characters that cannot be part of an environment variable's name), and thus it prints that error message.

To fix it: open your .bashrc, locate the line that starts with export ROS_PACKAGE_PATH and insert the =. Save, resource.

But note that I don't recommend manually changing ROS_PACKAGE_PATH`.

more