gitflow
gitflow copied to clipboard
getopt does not support spaces in arguments on Mac OS X
The bug is exposed as follows:
$ git flow init # accept the defaults
$ echo "foo" > foo
$ git add . && git commit -m 'Add foo' # on develop
$ git flow release start 0.1.0
$ echo "bar" > bar
$ git add . && git commit -m 'Add bar' # on release/0.1.0
$ git flow release finish -m "Test release" 0.1.0
flags:FATAL the available getopt does not support spaces in options
The space in the -m
flag contains a space that the Mac OS X getopt cannot deal with correctly, apparently.
Is there are a work around for this issue? I am working on OSX and to find a solution. Thanks in advance.
Because I am a big dork, I was using textmate as my git editor. I switched to a terminal editor (vi, pico, nano, etc) and didn't have any issues any longer.
This is probably happening because of the bug in #50 that may be fixed by #160 with variable expansion.
This one remains open and seems related to specific Mac OS X-only perils related to shFlags.
See my pull request https://github.com/nvie/gitflow/pull/223 for a workaround for this issue. I implemented an option that maps to 'git tag -F', reading the message from a file and avoiding the need to use an interactive editor.
I know I'm late to this party, but below are brief instructions for the method I and my colleagues use to install git-flow on OS X without the problems described above and in #50. This method boils down to two things:
- Use the latest version of git-flow in order to get the patch referenced in #160
- Use the latest version of shflags (which supports a user-specified getopt utility) with gnu-getopt
These instructions are excerpted from a longer document containing other installation alternatives using Homebrew, but none of them really bear mentioning here. They all involve some degree of bodging due to bugs or peculiarities, which doesn't seem necessary since a simpler method is available. I'd be happy to provide details for the curious. If and when a new release of git-flow percolates out to Homebrew, this should all be unnecessary.
Instructions:
Download and install latest git-flow with latest shflags:
$ git clone git://github.com/nvie/gitflow.git
$ cd gitflow
$ git svn clone -r HEAD http://shflags.googlecode.com/svn/trunk/source/1.0 shFlags
$ sudo make install
You could also do it without git:
$ curl -L https://github.com/nvie/gitflow/tarball/develop | tar --exclude '*shFlags' -s '/nvie-\(gitflow\)-[a-z0-9]\{1,\}/\1/' -xvf -
$ cd gitflow
$ curl -L -o gitflow-shFlags http://shflags.googlecode.com/svn/trunk/source/1.0/src/shflags
$ sudo make install
Install gnu-getopt (with Homebrew) and configure shflags to use it:
$ brew install gnu-getopt
$ echo 'export FLAGS_GETOPT_CMD="$(brew --prefix gnu-getopt)/bin/getopt"' >> ~/.bashrc
Start a new terminal session to make sure your login shell picked up FLAGS_GETOPT_CMD:
$ echo $FLAGS_GETOPT_CMD
which should return something like: /usr/local/Cellar/gnu-getopt/1.1.4/bin/getopt
It's 2017
and things have changed.
http://shflags.googlecode.com/svn/trunk/source/1.0/src/shflags
has moved and returns 404.
Instead use https://raw.githubusercontent.com/nvie/shFlags/master/src/shflags
Use below updated snippet to install git-flow
with shFlags
$ curl -L https://github.com/nvie/gitflow/tarball/develop | tar --exclude '*shFlags' -s '/nvie-\(gitflow\)-[a-z0-9]\{1,\}/\1/' -xvf -
$ cd gitflow
$ curl -L -o gitflow-shFlags https://raw.githubusercontent.com/nvie/shFlags/master/src/shflags
$ sudo make install
Then follow the rest of the instructions as:
Install gnu-getopt (with Homebrew) and configure shflags to use it:
$ brew install gnu-getopt
$ echo 'export FLAGS_GETOPT_CMD="$(brew --prefix gnu-getopt)/bin/getopt"' >> ~/.bashrc
Start a new terminal session to make sure your login shell picked up FLAGS_GETOPT_CMD:
$ echo $FLAGS_GETOPT_CMD
which should return something like: /usr/local/Cellar/gnu-getopt/1.1.4/bin/getopt
.
Retry whatever you're trying to do with it.
what if I did those steps and echo doesn't show anything? but .bashrc updated, terminal reloaded. MacBook-Pro-mac-2:~ loyi$ echo $FLAGS_GETOPT_CMD
MacBook-Pro-mac-2:~ loyi$
@kahurangitama could happen if you use another Shell, such as Zsh. http://zpalexander.com/switching-to-zsh/
I had to replace the aforementioned command with this one:
echo 'export FLAGS_GETOPT_CMD="$(brew --prefix gnu-getopt)/bin/getopt"' >> ~/.zshrc
(instead of ~/.bashrc
)
My solution for fixing.
I already installed git-flow
, not git-flow-avh
. So I manually run these things to solve it:
brew install git-flow-avh
brew link git-flow-avh -f
git-flow-avh
doesn't require you to setup FLAGS_GETOPT_CMD
anymore.
Returns: 4 packages were symlinked... etc...
Like @heymartinadams said with ZSH shell, here is my way to prevent conflict. Keep to setup .zsh setting like that will help you don't need to touch .zshrc
.bashrc
source ~/.profile
.zshrc
[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'
Hope any guy found this topic helpful!