Does not support spaces (or quotes?) #16

MikeSchroll opened this Issue Dec 21, 2011 · 4 comments


None yet
2 participants

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:
rake aborted!
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.


gma commented Dec 21, 2011

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: (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 ~/ 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


gma commented Aug 20, 2014

Fixed in 5696faf

gma closed this Aug 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment