ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

setup.bash error on OSX

asked 2013-06-14 08:18:13 -0500

Kevin gravatar image

I just reinstalled Groovy on OSX 10.8.4 using Homebrew. I moved my old ROS directory from /opt/ros to /opt/ros_old so this is a completely new install. Now when I do:

source /opt/ros/groovy/setup.bash

I get the following error:

[kevin@tardis ~]$ source /opt/ros/groovy/setup.bash
-bash: /opt/ros/groovy/etc/catkin/profile.d/05.catkin_make.bash: line 32: syntax error in conditional expression: unexpected token `('
-bash: /opt/ros/groovy/etc/catkin/profile.d/05.catkin_make.bash: line 32: syntax error near `-@(C'
-bash: /opt/ros/groovy/etc/catkin/profile.d/05.catkin_make.bash: line 32: `            if [[ ${words[i]} == -@(C|-directory) ]]; then'
-bash: /opt/ros/groovy/etc/catkin/profile.d/05.catkin_make_isolated.bash: line 30: syntax error in conditional expression: unexpected token `('
-bash: /opt/ros/groovy/etc/catkin/profile.d/05.catkin_make_isolated.bash: line 30: syntax error near `-@(C'
-bash: /opt/ros/groovy/etc/catkin/profile.d/05.catkin_make_isolated.bash: line 30: `            if [[ ${words[i]} == -@(C|-directory) ]]; then'

Any idea what is wrong? Things worked before with Groovy. I am using:

[kevin@tardis ~]$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
edit retag flag offensive close merge delete

Comments

The two environment hooks 05.catkin_make(_isolated).bash have been recently added to catkin to provide auto completion on these two scripts. The issue seems to be specific to OS X or your setup. On Ubuntu it works as expected. Can you try looking what in these files bothers your version of bash?

Dirk Thomas gravatar image Dirk Thomas  ( 2013-06-14 08:29:17 -0500 )edit

I have this version of bash: ∫ bash --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12) Copyright (C) 2007 Free Software Foundation, Inc.

William gravatar image William  ( 2013-06-14 08:33:24 -0500 )edit

I can source the setup.bash with no problems, but I cannot use the autocompletion, I get: bash: _init_completion: command not found

William gravatar image William  ( 2013-06-14 08:35:58 -0500 )edit

Can you try to replace ${#words[ with ${#COMP_WORDS[ (twice) and ${words[ with ${COMP_WORDS[ (four times) and see if that solves your problem?

Dirk Thomas gravatar image Dirk Thomas  ( 2013-06-14 09:50:03 -0500 )edit

Tried that, it didn't help.

Kevin gravatar image Kevin  ( 2013-06-14 11:37:26 -0500 )edit

If you could come up with some kind of version check we could make that part of the completion optional. But without being able to reproduce it I can't help much with that.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-06-14 12:03:41 -0500 )edit

why don't you just implement the solution below? The issue is really simple and involves expanding the or statement to look at --directory and -C instead of the original compound statement. I am not a bash guru, but I believe my solution is correct.

Kevin gravatar image Kevin  ( 2013-06-14 12:24:39 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2013-06-14 11:36:06 -0500

Kevin gravatar image

You can install bash 4.2.45 from Homebrew as @William has done. It appeared to help @Art. I still needed to change both 05.catkin_make.bash (line 32) and 05.catkin_make_isolated.bash (line 30) located in /opt/ros/groovy/etc/catkin/profile.d to if [[ ${words[i]} == --directory || ${words[i]} == -C ]]; then. For some reason my system doesn't like the ${words[i]} == -@(C|-directory) part of the original line.

edit flag offensive delete link more

Comments

Thanks! It works!

Artem gravatar image Artem  ( 2013-06-14 11:51:26 -0500 )edit

I applied the splitting of the condition upstream. The above patch still uses the variable "words" which is wrong. Auto completion won't work when having the -C / --directory options on the command line. The full patch looks like: http://goo.gl/lYtVC Thanks for testing this and providing feedback!

Dirk Thomas gravatar image Dirk Thomas  ( 2013-06-14 14:09:46 -0500 )edit

Sorry ... why is words wrong? That is what was originally there? Maybe I have misunderstood something?

Kevin gravatar image Kevin  ( 2013-06-14 15:27:29 -0500 )edit

Because it was wrong before already.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-06-14 15:46:07 -0500 )edit

When these changes will be in the main repository? Every time I build my catkin work space it replaces the corrected 05.catkin_make.bash with the bad one.

Artem gravatar image Artem  ( 2013-06-17 08:16:41 -0500 )edit

The changes are committed to the source repo. So as a workaround you could just check it out in your workspace. The next release of catkin will likely happen during this week. But it will be at least one or two weeks until it is available in the public repos.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-06-17 08:28:48 -0500 )edit
0

answered 2013-06-14 08:52:52 -0500

William gravatar image

So I did some tests:

  • bash-3.2.48 with no bash-completion
    • source setup.bash works
    • catkin_make -<tab><tab> gives bash: _init_completion: command not found
  • bash-3.2.48 with bash-completion (from homebrew)
    • source setup.bash works
    • . $(brew --prefix)/etc/bash_completion works
    • catkin_make -<tab><tab> gives bash: _init_completion: command not found
  • bash-3.2.48 with bash-completion2 (from homebrew/versions tap)
    • source setup.bash works
    • . $(brew --prefix)/share/bash-completion/bash_completion fails
  • bash-4.2.45 (from homebrew) with no bash-completion
    • source setup.bash works
    • catkin_make -<tab><tab> gives bash: _init_completion: command not found
  • bash-4.2.45 (from homebrew) with bash-completion (from homebrew)
    • source setup.bash works
    • . $(brew --prefix)/etc/bash_completion works
    • catkin_make -<tab><tab> gives bash: _init_completion: command not found
  • bash-4.2.45 (from homebrew) with bash-completion2 (from homebrew/versions tap)
    • source setup.bash works
    • . $(brew --prefix)/share/bash-completion/bash_completion works
    • catkin_make -<tab><tab> gives completions!

So to summarize, I never get your original error, but I don't get completions until I have bash-4.2.45 and bash-completion2 from the homebrew/versions tap.

edit flag offensive delete link more

Comments

1

No clue, I just installed bash 4.2.45 from homebrew and I get the same error. Something somewhere in my system is hosed. It sounds like it is just me and not an OSX issue, except for the issue William identified. Thanks for the help!

Kevin gravatar image Kevin  ( 2013-06-14 10:04:32 -0500 )edit

Kevin it's not only you. I've decided to rebuild my groovy just right now and I am getting the same errors. Following William's post I updated bash to 4.2.45.

Artem gravatar image Artem  ( 2013-06-14 11:01:12 -0500 )edit

@Art do you have the issue that @Kevin reported with the newer version of bash (4.2.45)?

William gravatar image William  ( 2013-06-14 11:02:27 -0500 )edit

Wow it's amazing! I opened up a new console tab and it's begun working like a charm! Yes I am using bash 4.2.45.

Artem gravatar image Artem  ( 2013-06-14 11:07:18 -0500 )edit

Everything seems to be fine if I replace if [[ ${words[i]} == -@(C|-directory) ]]; then in catkin_make and catkin_make_isolated with if [[ ${words[i]} == --directory || ${words[i]} == -C ]]; then

Kevin gravatar image Kevin  ( 2013-06-14 11:10:37 -0500 )edit

Question Tools

Stats

Asked: 2013-06-14 08:18:13 -0500

Seen: 951 times

Last updated: Jun 14 '13