0

I'm trying to compile Gazebo on my Ubuntu 17.04.

I'm following this instructions, but it seems to be an error in the following one:

sudo apt-get install $(sed 's:\\ ::g' <<< $BASE_DEPENDENCIES) $(sed 's:\\ ::g' <<< $GAZEBO_BASE_DEPENDENCIES)

I don't understand what is doing here: sed 's:\\ ::g'

When I run the previous command sudo apt-get install ... I get the following error 42 times:

E: Unable to locate package \

I have echoed both variables.

echo $BASE_DEPENDENCIES
build-essential \ cmake \ debhelper \ mesa-utils \ cppcheck \ xsltproc \ python-psutil \ python \ bc \ netcat-openbsd \ gnupg2 \ net-tools \ locales

And the other one:

echo $GAZEBO_BASE_DEPENDENCIES
libfreeimage-dev \ libprotoc-dev \ libprotobuf-dev \ protobuf-compiler \ freeglut3-dev \ libcurl4-openssl-dev \ libtinyxml-dev \ libtar-dev \ libtbb-dev \ libogre-1.9-dev \ libxml2-dev \ pkg-config \ qtbase5-dev \ libqwt-qt5-dev \ libltdl-dev \ libgts-dev \ libboost-thread-dev \ libboost-signals-dev \ libboost-system-dev \ libboost-filesystem-dev \ libboost-program-options-dev \ libboost-regex-dev \ libboost-iostreams-dev \ libbullet-dev \ libsimbody-dev \ \ libignition-transport3-dev \ libignition-math3-dev \ libignition-msgs-dev \ libtinyxml2-dev \ libsdformat5-dev

The output for the command sed 's:\\ ::g' <<< $BASE_DEPENDENCIES is:

build-essential \
                   cmake           \
                   debhelper       \
                   mesa-utils      \
                   cppcheck        \
                   xsltproc        \
                   python-psutil   \
                   python          \
                   bc              \
                   netcat-openbsd  \
                   gnupg2          \
                   net-tools       \
                   locales

UPDATE
I have tried the command sed 's:\\[[:space:]]::g' <<< $BASE_DEPENDENCIES with the following output:

user@Mpc:~$ sed 's:\\[[:space:]]::g' <<< $BASE_DEPENDENCIES
build-essential \
                   cmake           \
                   debhelper       \
                   mesa-utils      \
                   cppcheck        \
                   xsltproc        \
                   python-psutil   \
                   python          \
                   bc              \
                   netcat-openbsd  \
                   gnupg2          \
                   net-tools       \
                   locales

UPDATE 2
It seems that the sed command is ok. If I do the following, without using the env variable I get the right string:

user@pc:~$ echo 'build-essential \ cmake \ debhelper \ mesa-utils \ cppcheck \ xsltproc \ python-psutil \ python \ bc \ netcat-openbsd \ gnupg2 \ net-tools \ locales' | sed 's:\\ ::g'
build-essential cmake debhelper mesa-utils cppcheck xsltproc python-psutil python bc netcat-openbsd gnupg2 net-tools locales

UPDATE 3
If I surround the env. vars. and echoed I get the newlines and the spaces. But if I echo them without the quotes I get all in one line.

And if I use sed with the env. var without quotes I get the value of the variable with new lines and spaces.

How can I fix this error?

  • The sed command is supposed to remove all backslashes from the variable contents. Obviously it doesn't work, but at the moment I can't see why. Please give the output of sed 's:\\ ::g' <<< $BASE_DEPENDENCIES – Philippos Oct 18 '17 at 15:07
  • The sed statement is taking the output from the variable BASE_DEPENDANCIES and GAZEBO_BASE_DEPENDANCIES and removing the back slashes followed by space (two back slashes to escape the back slash). It seems that there maybe two back slashes together in one of the variables? – Raman Sailopal Oct 18 '17 at 15:08
  • If the value of those variables were assigned properly, you would not need to jump through these hoops. Where do they get their values from? – Kusalananda Oct 18 '17 at 15:09
  • Also, are you sure there is a space after all of the back slashes? – Raman Sailopal Oct 18 '17 at 15:10
  • @Philippos I have updated the question with output you need. – VansFannel Oct 18 '17 at 15:16
0

The sed command is supposed to remove all backslashes from the variable contents, but it expects the backslashes to be followed by spaces. But it seems they are followed by newlines, so use

sed -z 's:\\[[:space:]]::g'

instead (this is for GNU sed, only, but since you are on Ubuntu ...).

  • Thanks for your answer but I get the same error. – VansFannel Oct 18 '17 at 15:46
  • Did you replace both? Then please post the output for the changed command. – Philippos Oct 18 '17 at 15:51
  • I have updated the question with the output of your command. – VansFannel Oct 18 '17 at 15:54
  • You are right, The backslashes are followed by newlines. I don't understand why you use [[:space:]] instead of newline. – VansFannel Oct 18 '17 at 16:06
  • Sorry, i forgot to add the -z option to process all lines in the same buffer. Without that, each lines is processed alone and doesn't contain newlines of course. – Philippos Oct 18 '17 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.