GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
When I run a rake command related to Octopress (using Jekyll) to create a new blog post, I type:
rake new_post["Post title"]
This normally works great; however once I enabled bundler-exec, I received the error:
Don't know how to build task 'new_post[Post'
I confess to not being sure exactly where the problem is; but it would seem somewhere along the lines the quotes are being interpreted, and lost, and not passed on, and so then the spaces become a problem.
Hi Mike. This is a tricky one.
This line is the one that passes your command line arguments on to bundle exec:
The $@ variable is explained here: http://tldp.org/LDP/abs/html/internalvariables.html#ARGLIST (scroll up a bit).
The rake command is behaving in a surprising (to me) way there. You'd normally expect 'new_post["' and 'Post title"]' to be separate arguments, and if you run that in your shell without bundler-exec involved, I think the shell will pass them to rake as separate arguments. I suspect rake is joining the arguments up before it does anything with them, in a slightly non-standard way. It may be that the way Rake does this is getting broken slightly by the way bundle exec is getting called.
If you prefix the command with bundle exec yourself does it do the right thing?
So I could change the line I linked to above to do this:
bundle exec "$@"
but what worries me there is that that would pass all the arguments to bundle exec as a single argument. This might fix your rake tasks, but might not play ball with the other commands that get wrapped. It'd need some fairly intensive testing or poking around to see what's happening. That doesn't stop you from trying it locally though!
If I were you I'd try changing line 32 to these alternatives, and see what happens:
bundle exec "$@"
bundle exec "$*"
bundle exec $*
If you try, I'd be interested to know which work...
So just to confirm, running bundle exec new_post["test title"] works (and always has)
Surprising to both of us, bundle exec "$@" solves the problem, none of the others work.
(tested by editing ~/.bundler-exec.sh line 32 and then spawning a new shell)
It does say... at the source you provided:
"Of course, "$@" should be quoted."
I take that to mean we have a winning solution!
Just realized the project originally had the args quoted - but was removed in this commit: 3301c3b
Fixed in 5696faf