0
$\begingroup$

Rosanswers logo

I'm trying to install ROS Kinetic, and it keeps failing at various points in the catkin_make process, most notably and most frequently like so:

I ran:

source /opt/ros/kinetic/setup.bash

(sometimes I get the following)

-bash: /tmp/setup.sh.SIm4vZkcV4: line 38: unexpected EOF while looking for matching `"'
-bash: /tmp/setup.sh.SIm4vZkcV4: line 39: syntax error: unexpected end of file
-bash: [: 0: unary operator expected

and then

catkin_make

And here's the output:

 Base path: /home/ubuntu/catkin_ws
Source space: /home/ubuntu/catkin_ws/src
Build space: /home/ubuntu/catkin_ws/build
Devel space: /home/ubuntu/catkin_ws/devel
Install space: /home/ubuntu/catkin_ws/install
####
#### Running command: "cmake /home/ubuntu/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/ubuntu/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/ubuntu/catkin_ws/install -G Unix Makefiles" in "/home/ubuntu/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/ubuntu/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.12", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/ubuntu/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.12") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.18
-- BUILD_SHARED_LIBS is on
/home/ubuntu/catkin_ws/devel/env.sh: 31: /tmp/setup.sh.URSsHUDdg8: Syntax error: Unterminated quoted string
Traceback (most recent call last):
  File "/home/ubuntu/catkin_ws/build/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/ubuntu/catkin_ws/devel/env.sh')
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/environment_cache.py", line 61, in generate_environment_script
    output = subprocess.check_output([env_script, sys.executable, '-c', python_code])
  File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['/home/ubuntu/catkin_ws/devel/env.sh', '/usr/bin/python2', '-c', 'import os; print(dict(os.environ))']' returned non-zero exit status 2
CMake Error at /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python2
  "/home/ubuntu/catkin_ws/build/catkin_generated/generate_cached_setup.py")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/all.cmake:207 (safe_execute_process)
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:56 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/ubuntu/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

No matter what, I seem to be having an error in the auto-generated setup.sh file. Not sure how to proceed from here.

REQUESTED INFO EDITS:

followed the instructions on the install page (https://wiki.ros.org/kinetic/Installation/Ubuntu)

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
$ sudo apt-get update
$ sudo apt-get install ros-kinetic-ros-base
$ sudo rosdep init
$ rosdep update
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
    -bash: /tmp/setup.sh.x48OsSuFZk: line 38: unexpected EOF while looking for matching `"'
    -bash: /tmp/setup.sh.x48OsSuFZk: line 39: syntax error: unexpected end of file
    -bash: [: 0: unary operator expected
$ sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

And then I ran the same stuff as above. the syntax error there seems to be a problem.

lsb_release -a returns:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:    16.04
Codename:   xenial

uname -rmvp returns:

 3.10.0 #5 SMP PREEMPT Fri Dec 30 18:17:17 CST 2016 armv7l armv7l

printf %q "$IFS";

$' \t\n'

ps -p $$:

  PID TTY          TIME CMD
 1805 pts/7    00:00:00 bash

setup.bash:

!/usr/bin/env bash
# generated from catkin/cmake/templates/setup.bash.in

CATKIN_SHELL=bash

# source setup.sh from same directory as this file
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
. "$_CATKIN_SETUP_DIR/setup.sh"

setup.sh:

#!/usr/bin/env sh
# generated from catkin/cmake/template/setup.sh.in

# Sets various environment variables and sources additional environment hooks.
# It tries it's best to undo changes from a previously sourced setup file before.
# Supported command line options:
# --extend: skips the undoing of changes from a previously sourced setup file
# --local: only considers this workspace but not the chained ones
# In plain sh shell which doesn't support arguments for sourced scripts you can
# set the environment variable `CATKIN_SETUP_UTIL_ARGS=--extend/--local` instead.

# since this file is sourced either use the provided _CATKIN_SETUP_DIR
# or fall back to the destination set at configure time
: ${_CATKIN_SETUP_DIR:=/opt/ros/kinetic}
_SETUP_UTIL="$_CATKIN_SETUP_DIR/_setup_util.py"
unset _CATKIN_SETUP_DIR

if [ ! -f "$_SETUP_UTIL" ]; then
  echo "Missing Python script: $_SETUP_UTIL"
  return 22
fi

# detect if running on Darwin platform
_UNAME=`uname -s`
_IS_DARWIN=0
if [ "$_UNAME" = "Darwin" ]; then
  _IS_DARWIN=1
fi
unset _UNAME

# make sure to export all environment variables
export CMAKE_PREFIX_PATH
if [ $_IS_DARWIN -eq 0 ]; then
  export LD_LIBRARY_PATH
else
  export DYLD_LIBRARY_PATH
fi
unset _IS_DARWIN
export PATH
export PKG_CONFIG_PATH
export PYTHONPATH

# remember type of shell if not already set
if [ -z "$CATKIN_SHELL" ]; then
  CATKIN_SHELL=sh
fi

# invoke Python script to generate necessary exports of environment variables
# use TMPDIR if it exists, otherwise fall back to /tmp
if [ -d "${TMPDIR:-}" ]; then
  _TMPDIR="${TMPDIR}"
else
  _TMPDIR=/tmp
fi
_SETUP_TMP=`mktemp "${_TMPDIR}/setup.sh.XXXXXXXXXX"`
unset _TMPDIR
if [ $? -ne 0 -o ! -f "$_SETUP_TMP" ]; then
  echo "Could not create temporary file: $_SETUP_TMP"
  return 1
fi
CATKIN_SHELL=$CATKIN_SHELL "$_SETUP_UTIL" $@ ${CATKIN_SETUP_UTIL_ARGS:-} >> "$_SETUP_TMP"
_RC=$?
if [ $_RC -ne 0 ]; then
  if [ $_RC -eq 2 ]; then
    echo "Could not write the output of '$_SETUP_UTIL' to temporary file '$_SETUP_TMP': may be the disk if full?"
  else
    echo "Failed to run '\"$_SETUP_UTIL\" $@': return code $_RC"
  fi
  unset _RC
  unset _SETUP_UTIL
  #rm -f "$_SETUP_TMP"
  unset _SETUP_TMP
  return 1
fi
unset _RC
unset _SETUP_UTIL
. "$_SETUP_TMP"
#rm -f "$_SETUP_TMP"
unset _SETUP_TMP

# source all environment hooks
_i=0
while [ $_i -lt $_CATKIN_ENVIRONMENT_HOOKS_COUNT ]; do
  eval _envfile=\\\$_CATKIN_ENVIRONMENT_HOOKS_$_i
  unset _CATKIN_ENVIRONMENT_HOOKS_$_i
  eval _envfile_workspace=\\\$_CATKIN_ENVIRONMENT_HOOKS_${_i}_WORKSPACE
  unset _CATKIN_ENVIRONMENT_HOOKS_${_i}_WORKSPACE
  # set workspace for environment hook
  CATKIN_ENV_HOOK_WORKSPACE=$_envfile_workspace
  . "$_envfile"
  unset CATKIN_ENV_HOOK_WORKSPACE
  _i=$((_i + 1))
done
unset _i

unset _CATKIN_ENVIRONMENT_HOOKS_COUNT

/tmp/setup.sh.WHATEVER:

# prepend folders of workspaces to environment variables
export CMAKE_PREFIX_PATH="/opt/ros/kinetic"
export LD_LIBRARY_PATH="/opt/ros/kinetic/lib"
export PATH="$PATH"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
export PYTHONPATH="$PYTHONPATH"
# found environment hooks in workspaces
export _CATKIN_ENVIRONMENT_HOOKS_COUNT="12"
export _CATKIN_ENVIRONMENT_HOOKS_0="/opt/ros/kinetic/etc/catkin/profile.d/1.ros_distro.sh"
export _CATKIN_ENVIRONMENT_HOOKS_0_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_1="/opt/ros/kinetic/etc/catkin/profile.d/1.ros_etc_dir.sh"
export _CATKIN_ENVIRONMENT_HOOKS_1_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_2="/opt/ros/kinetic/etc/catkin/profile.d/1.ros_package_path.sh"
export _CATKIN_ENVIRONMENT_HOOKS_2_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_3="/opt/ros/kinetic/etc/catkin/profile.d/1.ros_python_version.sh"
export _CATKIN_ENVIRONMENT_HOOKS_3_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_4="/opt/ros/kinetic/etc/catkin/profile.d/1.ros_version.sh"
export _CATKIN_ENVIRONMENT_HOOKS_4_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_5="/opt/ros/kinetic/etc/catkin/profile.d/10.rosbuild.sh"
export _CATKIN_ENVIRONMENT_HOOKS_5_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_6="/opt/ros/kinetic/etc/catkin/profile.d/10.roslaunch.sh"
export _CATKIN_ENVIRONMENT_HOOKS_6_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_7="/opt/ros/kinetic/etc/catkin/profile.d/99.roslisp.sh"
export _CATKIN_ENVIRONMENT_HOOKS_7_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_8="/opt/ros/kinetic/etc/catkin/profile.d/05.catkin_make.bash"
export _CATKIN_ENVIRONMENT_HOOKS_8_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_9="/opt/ros/kinetic/etc/catkin/profile.d/05.catkin_make_isolated.bash"
export _CATKIN_ENVIRONMENT_HOOKS_9_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_10="/opt/ros/kinetic/etc/catkin/profile.d/15.rosbash.bash"
export _CATKIN_ENVIRONMENT_HOOKS_10_WORKSPACE="/opt/ros/kinetic"
export _CATKIN_ENVIRONMENT_HOOKS_11="/opt/ros/kinetic/etc/catkin/profile.d/20.transform.bash"
export _CATKIN_ENVIRONMENT_HOOKS_11_WORKSPACE="/opt/ros/kinetic"

env:

LC_PAPER=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
XDG_SESSION_ID=35
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM=xterm-256color
SHELL=/bin/bash
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
LC_NUMERIC=en_US.UTF-8
ROS_PYTHON_VERSION=2
ROS_VERSION=1
SSH_TTY=/dev/pts/6
LC_ALL=en_US.UTF-8",
USER=ubuntu
LD_LIBRARY_PATH=
LC_TELEPHONE=en_US.UTF-8
WORKON_HOME=/home/ubuntu/.virtualenvs
PATH=/opt/ros/kinetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games",
VIRTUALENVWRAPPER_HOOK_DIR=/home/ubuntu/.virtualenvs
LC_IDENTIFICATION=en_US.UTF-8
PWD=/home/ubuntu
LC_MEASUREMENT=en_US.UTF-8
ROSLISP_PACKAGE_DIRECTORIES=
SHLVL=1
HOME=/home/ubuntu
ROS_DISTRO=kinetic
LANGUAGE=en
PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages
LOGNAME=ubuntu
LC_CTYPE=UTF-8",
PKG_CONFIG_PATH=/opt/ros/kinetic/lib/pkgconfig
LESSOPEN=| /usr/bin/lesspipe %s
VIRTUALENVWRAPPER_WORKON_CD=1
CMAKE_PREFIX_PATH=
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
LC_NAME=en_US.UTF-8
_=/usr/bin/env

Originally posted by greentreefrog8 on ROS Answers with karma: 3 on 2020-01-04

Post score: 0


Original comments

Comment by gvdhoorn on 2020-01-05:
Are you building Kinetic from source?

Comment by greentreefrog8 on 2020-01-05:
I was not, but now I am. Same syntax error.

Comment by gvdhoorn on 2020-01-05:\

I was not, but now I am

Why?

Comment by greentreefrog8 on 2020-01-05:
I thought there would be a different outcome. There was not.

Comment by gvdhoorn on 2020-01-06:
If you don't have a good reason to build from source (and this goes for all packages, not just the "base ROS install"), then don't do it. Always try (hard) to use binary (ie: released) packages.

Please remove the Catkin workspace in which you were trying to build before, and make sure you've installed Kinetic using apt.

As to your problem: please tell us what you did exactly (ie: how you installed ROS). Also include the output of lsb_release -a, uname -rvmp, printf %q "$IFS" and ps -p $$ (note the double dollar sign).

Comment by greentreefrog8 on 2020-01-06:
I've added to the information above.

Comment by gvdhoorn on 2020-01-06:
Just for completeness, could you show the contents of /opt/ros/kinetic/setup.bash and /opt/ros/kinetic/setup.sh?

And based on the armv7l in the uname output you appear to be running this on an arm platform (RPi by any chance?).

That is not necessarily a problem, but would have been good to mention.

I would recommend to remove the source /opt/ros/kinetic/setup.bash line from your .bashrc for now. It's not needed (you can do it manually) and it would unbreak your setup for now.

Comment by gvdhoorn on 2020-01-06:
As a test, please run this sed command (copy-paste it, it's a single command line):

sudo sed -i 's|rm -f "$_SETUP_TMP"|#rm -f "$_SETUP_TMP"|g' /opt/ros/kinetic/setup.sh

This will make setup.sh not delete the temporary setup.sh file it creates in the /tmp directory so we can take a look at it.

Then open a new terminal, type source /opt/ros/kinetic/setup.bash. It will probably still fail.

But now there should be a file called /tmp/setup.sh.SOME_RANDOM_CHARACTERS. Open it with less /tmp/setup.sh.SOME_RANDOM_CHARACTERS (obviously replace SOME_RANDOM_CHARACTERS with whatever is there on your machine).

Copy the contents of this file and append it to your question text.


There might be a special character in your username, or home directory or something else that breaks parsing of the setup file.

Comment by greentreefrog8 on 2020-01-06:
Yeah, it's an arm processor. Not an RPi. Sorry, I didn't realize it was important.

the sed command does nothing? removing the line from the .bashrc would unbreak my setup, but the issue with the setup.sh still persists.

I'm noticing that the syntax error shows on line 38/39, or line 31. Lines 38/39 don't exist.

Comment by Dirk Thomas on 2020-01-07:
Can you share the output of env without sourcing the setup file? Maybe that provides some insight.

Comment by gvdhoorn on 2020-01-07:
I don't see anything out of the ordinary in the files shown. There may be something unexpected in the environment, so running env before sourceing anything would be a good check.

Comment by greentreefrog8 on 2020-01-07:
env is up there too now. The only thing I can think of is to remove all the ROS stuff from my environment variables, uninstall ROS, and let it set up everything again.

Comment by gvdhoorn on 2020-01-07:\

The only thing I can think of is to remove all the ROS stuff from my environment variables, uninstall ROS, and let it set up everything again.

this would not change anything.

Your environment is incorrectly setup. There should not be any quotes, commas or such characters in there.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Several of your environment variable contain a single double quote: LC_ALL, PATH, LC_CTYPE. Please fix those to not contain quotes. I would expect it to work after that.


Originally posted by Dirk Thomas with karma: 16276 on 2020-01-07

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by gvdhoorn on 2020-01-07:
Converted this to an answer as this most likely is the answer.

Comment by greentreefrog8 on 2020-01-07:
yup, that was it. Thanks for your patience, y'all!

Comment by gvdhoorn on 2020-01-07:
Please mark the question as answered by ticking the checkmark (✓) to the left of the answer. Thanks.

Comment by dinesh on 2020-03-28:
i'm also getting this error. but i'm not able to fix it. isn't it setup.sh file which should be modifed and quotes to be checed?

Comment by greentreefrog8 on 2020-03-29:
No, you should just modify your environment variables

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.