5

why does zsh ask to correct rspec to spec when running bundler?

✗ rspec --version
2.12.2
✗ bundle exec rspec --version
zsh: correct 'rspec' to 'spec' [nyae]? n
2.12.2

system:

  • ubuntu 12.10
  • using rvm

how do I fix this? Thanks!

UPDATE:

hitting ctrl-x h on bundle exec as asked by @mpy

 ✗ bundle exec
tags in context :completion::complete:bundle::
    all-files  (_files _default (eval))

UPDATE 2:

[[ -o correctall ]] && echo enabled
enabled   # on both machines

Answer to comment: spec is a directory

I followed the Manual Installation from https://github.com/zsh-users/zsh-completions

✗ echo $fpath
/home/ole/app/zsh-completions/src /scripts/zsh/Completion /home/ole/.oh-my-zsh/plugins/ruby /home/ole/.oh-my-zsh/plugins/bundler /home/ole/.oh-my-zsh/plugins/zeus /home/ole/.oh-my-zsh/plugins/rvm /home/ole/.oh-my-zsh/plugins/rails3 /home/ole/.oh-my-zsh/plugins/git-extras /home/ole/.oh-my-zsh/plugins/git-flow /home/ole/.oh-my-zsh/plugins/git /home/ole/.oh-my-zsh/functions /home/ole/.oh-my-zsh/completions /usr/local/share/zsh/site-functions /usr/share/zsh/vendor-functions /usr/share/zsh/vendor-completions /usr/share/zsh/functions/Calendar /usr/share/zsh/functions/Chpwd /usr/share/zsh/functions/Completion /usr/share/zsh/functions/Completion/AIX /usr/share/zsh/functions/Completion/BSD /usr/share/zsh/functions/Completion/Base /usr/share/zsh/functions/Completion/Cygwin /usr/share/zsh/functions/Completion/Darwin /usr/share/zsh/functions/Completion/Debian /usr/share/zsh/functions/Completion/Linux /usr/share/zsh/functions/Completion/Mandriva /usr/share/zsh/functions/Completion/Redhat /usr/share/zsh/functions/Completion/Solaris /usr/share/zsh/functions/Completion/Unix /usr/share/zsh/functions/Completion/X /usr/share/zsh/functions/Completion/Zsh /usr/share/zsh/functions/Completion/openSUSE /usr/share/zsh/functions/Exceptions /usr/share/zsh/functions/MIME /usr/share/zsh/functions/Misc /usr/share/zsh/functions/Newuser /usr/share/zsh/functions/Prompts /usr/share/zsh/functions/TCP /usr/share/zsh/functions/VCS_Info /usr/share/zsh/functions/VCS_Info/Backends /usr/share/zsh/functions/Zftp /usr/share/zsh/functions/Zle

$fpath changed. It had no effect.

excerpt from my .zshrc

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)

plugins=(git git-flow git-extras rails3 rvm zeus bundler ruby)

source $ZSH/oh-my-zsh.sh   

# Customize to your needs...
export PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

PATH=$PATH:/usr/lib/postgresql/9.1/bin/
export JAVA_HOME=$HOME/app/jdk1.7.0_15

fpath=($HOME/app/zsh-completions/src $fpath)

my changes wore

- plugins=(git rails ruby)
+ plugins=(git git-flow git-extras rails3 rvm zeus bundler ruby)

+ fpath=($HOME/app/zsh-completions/src $fpath)

and this had no effect. The error persist (I open a new terminal tab each time)

ᔕᖺᘎᕊ
  • 6,393
oma
  • 161

2 Answers2

4

Because it thinks rspec is a misspelling of spec?

  • You can use nocorrect (e.g. alias bundle='nocorrect bundle'),
  • or just stop using command line correction altogether.
  • or use CORRECT instead of CORRECT_ALL which is what you seem to be using

[edit] Notice zsh is using the completer functions to determine what to expect. In the secnd case it is using the completer for bundle

Francisco
  • 2,418
2

Automatic spell checking can be actived in two ways (I use "From bash to Z Shell" by O. Kiddle et al. as a guide/reference):

  • setopt correct

    After pressing Enter zsh "looks at the command word, and if doesn't recognize it as a command it tries to find a correction, which then offers to you."

  • setopt correctall

    Like correct, but in addition checks the "arguments after the command. However, it simply assumens they are files, and tries to correct the words to filenames. Often isn't what you want."

So, the latter explains, why you get spec offered as correction for rspec -- zsh thinks that should be a file (or in your case a directory). It does not explain, why it's working on the other machine. (I suppose some different setup in both your personal or global config files (~/.zshrc or /etc/zsh/), less likely a version issue.)

[Closely related to this rather simple spell checking is a feature of the completion system, called "approximate completion". The completion system is zsh is very advanced an is worth a study of its own.(*) As I don't use that "approximate completion" myself I want to direct you to man zshcompsys, Section "CONTROL FUNCTIONS" _approximate. if you are interested.]

But, unless you have special reasons for that, I would use unsetopt correctall && setopt correct to get rid of the described behavior (that's the last point proposed by Francisco) and use a decent completion function for `bundle (that's my last comment).

With the aid of completion fucntions zsh gets rather "smart". So it knows for example that after sudo a command must follow, hence sudo passTAB will complete to sudo passwd. You use bundle, for which there's also a completion function, but obviously not shipped by default.(**) With that you will get a nice reminder of bundle's options:

$ bundle -TAB-
check     -- Determine whether the requirements for your application are installed
config    -- Specify and read configuration options for bundler
console   -- Start an IRB session in the context of the current bundle
exec      -- Execute a script in the context of the current bundle
gem       -- Create a simple gem, suitable for development with bundler
...

and after typing bundle exec you'll get only commands presented. I prefer that behavior much more than correction, but it's up to you.


(*) It's activated by autoload -U compinit && compinit. To check if it's active (it probably is), use which compinit:

$ zsh -f

$ which compinit
compinit not found

$ autoload -U compinit

$ which compinit
compinit () {
# undefined
builtin autoload -XU
}

(**) Copy https://github.com/zsh-users/zsh-completions/blob/master/src/_bundle to a directory which is in your $fpath

mpy
  • 28,816