Remove the ps='ps ...'
from your config, like .bashrc, or execute unalias ps
and then run your RVM command.
Source RVM script - "grep: invalid option -- 'p'"
Question
Whenever I try to use RVM on Ubuntu or one of it's derivatives, I get the following error:
grep: invalid option -- 'p'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
I checked type grep
, and got
grep is /bin/grep
.
So grep is not aliased.
Is this a known bug in RVM? If not, what else could be causing this behavior?
EDIT: This occurs when I source ~/.bash_profile
. I've gone and reproduced the behavior when I run just the RVM related part.
Solution 2
OTHER TIPS
I had exactly the same symptom intermittently:
$ grep anything *
grep: invalid option -- 'p'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
In my case it was actually a file in that directory starting with -
:
$ ls ./'-'*
./-p
The solution for me was just to remove the file:
$ rm ./"-p"
$ ls ./'-'*
ls: cannot access ./-*: No such file or directory
$ grep anything *
grep: *: No such file or directory
Turns out it was another command RVM was using that I had aliased.
99 times out of 100, when I'm using ps
, I'm doing ps -aux | grep $SOMETHING
. In my .bashrc, I have alias ps='ps aux | grep'
. In RVM, ps
is used with the '-p' flag. With this alias, it was registering as ps aux | grep -p
.
For me I was grepping "-swap" which grep interprets as parameters. Solution is echo something | grep -- "-swap"