stecman / symfony-console-completion

Automatic tab-key completion for Symfony console application options, arguments and parameters
MIT License
420 stars 26 forks source link

Unable to install on OSX Snow Leopard #56

Closed aik099 closed 8 years ago

aik099 commented 8 years ago

Used installation methods:

# BASH ~3.x, ZSH
[program] _completion --generate-hook | source /dev/stdin

# BASH (any version)
eval $([program] _completion --generate-hook)

The 1st method:

The 2nd method:

-bash: syntax error near unexpected token `('

Output of bash --version:

GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.

P.S. The installation method proposed by program help _completion command doesn't work at all:

eval `[program] _completion -g`
pjcdawkins commented 8 years ago

Try this one?

source <([program] _completion -g)
aik099 commented 8 years ago

On README.md it's told that it works only on Bash 4, so I haven't tried.

If I run this, then instead of proper auto-complete I get program word (the used program name) added on each TAB press.

stecman commented 8 years ago

The version numbers are kind of best guesses as it seems to vary system to system which ones actually work.

It sounds like the hook might be working, but maybe something else isn't; it wouldnt be doing anything if the hook didn't register. Have you tried dumping the CMDLINE_CONTENTS and cursor variables in the hook code?

aik099 commented 8 years ago

Without hook pressing TAB shows files in current folder. So hook definitely working and fact, that it's telling program as possible auto-complete result sounds like a bug in it.

aik099 commented 8 years ago

I've tried to write down generate hook to the file to see what's wrong with it. And I've found that 2nd line contains this:

Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings.

I guess according to PHP settings:

Same error is then present in list of auto-completed values returned from application to the bash.

Regardless to that the _completion command must do ini_set('display_errors', 'off') when:


Now I have this returned instead of auto-completed values:

-bash: _get_comp_words_by_ref: command not found

Google tells, that I might have bash_completion not installed. Here I'd suggest checking for that and returning nice error back (at hook invocation, not generation time) to user so that that he'll know what to do.

stecman commented 8 years ago

Ah right, that makes sense. Nice find. Might need to play around with that fix you're suggesting so that it doesn't hide any other errors inadvertently.. Im not at a computer right now to check, but isn't that date/timezone error printed quite early on in execution?

It'd be nice not to have the dependency on the bash-completion package (see #36), but it means we'll need another way around allowing colons in completion results (that's all it's used for). Will happily accept a PR for a nicer notice as a temporary measure though.

aik099 commented 8 years ago

Ah right, that makes sense. Nice find. Might need to play around with that fix you're suggesting so that it doesn't hide any other errors inadvertently..

It's the opposite I've suggested: hide any PHP notices/warnings when _complete command runs in any form (e.g. hook generation, completion preparation).

Im not at a computer right now to check, but isn't that date/timezone error printed quite early on in execution?

Yes, it's first thing that is printed. Even before function ... line, where completion function is defined.

It'd be nice not to have the dependency on the bash-completion package (see #36), but it means we'll need another way around allowing colons in completion results (that's all it's used for).

We can't add it as a dependency, because we also support ZSH.

Will happily accept a PR for a nicer notice as a temporary measure though.

Do you know how to check if that Bash function is defined?

stecman commented 8 years ago

@aik099 - The date_default_timezone_get function isn't used in this library or any of its dependencies. Is your application using it in this case (anywhere in the bootstrap process would cause this).

Also, what PHP version does this system run?

aik099 commented 8 years ago

Is your application using it in this case (anywhere in the bootstrap process would cause this).

Yes, the application use date_default_timezone_get function.

Also, what PHP version does this system run?

5.3.26

aik099 commented 8 years ago

I've created #58 PR with check for installed bash-completion package before defining hook in Bash.

Since date_default_timezone_get is called during application initialization, but before the CompletionCommand constructor we don't have any power to alter error reporting setting from there. I suggest we just ignore this use case (when date.timezone setting wasn't set in PHP).

stecman commented 8 years ago

Thanks, @aik099. I agree that other than flagging it in the docs, there's not much that can be done for the warning issue. I've merged your PR with a small tweak to the message.