Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows git bash does not support grep -o option #75

Closed
mcollina opened this issue Oct 26, 2011 · 20 comments
Closed

windows git bash does not support grep -o option #75

mcollina opened this issue Oct 26, 2011 · 20 comments
Labels
non-issue / invalid This isn't relevant to nvm, or turned out to be something unrelated. OS: windows

Comments

@mcollina
Copy link

I've just installed nvm and as I type "nvm install 0.4.12" on mac os x lion it outputs:

nvm: install N/A failed!
@creationix
Copy link
Collaborator

you need to put the v in front. For example nvm install v0.4.12.

@willbowling
Copy link

$ nvm install v0.6.14

results in the following...

grep: invalid option -- o
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
Additional options while compiling:
nvm: install N/A failed!

please assist.

@RichFromGalvanize
Copy link

Having the same issue on Windows 7 using git bash.

@vinaydotblog
Copy link

I am getting same error message.

@koenpunt
Copy link
Contributor

grep is never called with the o option, only egrep, so can it be that egrep is a symlink to grep?

@funseiki
Copy link

I'm also having this issue on Windows 7 git bash - any fixes as of yet?

@mikeumus
Copy link

I'm having this issue as well with git bash on Windows 8.

@ljharb
Copy link
Member

ljharb commented Sep 18, 2013

@koenpunt -o is a perfectly valid option for grep - and egrep as far as I know is just an alias for grep -e.

@mikeumus / @funseiki : can you provide a gist showing the command line input and output?

@mikeumus
Copy link

@ljharb
Copy link
Member

ljharb commented Sep 18, 2013

Thanks @mikeumus! OK, then this sounds like it might be an issue with git bash in Windows not supporting the -o option on grep.

I'm reopening this issue and will adjust the title to reflect that.

@ljharb ljharb reopened this Sep 18, 2013
@UltCombo
Copy link

Since this is one of the first google results for git bash's seemingly terribly outdated grep problem, I'll post a temporary workaround here.

Open <Git install directory>/bin and overwrite grep.exe with a more up to date version. I found two alternatives that provide -o support:

  • GnuWin32's grep 2.5.4 (dl).
  • ezwinports' grep 2.10 (dl). Note: You also have to extract libprce-0.dll in the same folder as grep.

Though ezwinports' grep port is much more up to date, I can't say whether any of these will cause stability/compatibility issues. I haven't found any issues yet, but use it at your own risk.

@tomByrer
Copy link
Contributor

tomByrer commented Dec 2, 2013

Works great @UltCombo !
I would note that only grep.exe & libprce-0.dll are needed to copy into git\bin, since egrep & fgrep are already aliased in the Git Bash distro.
I also have a personal habit of renaming the old files as *name*_old.*ext*, incase one has to rollback.

@tomByrer
Copy link
Contributor

tomByrer commented Dec 2, 2013

Seems that there is no -o flag for [e]grep either.
Use sed instead?

@qkdreyer
Copy link

You can also check this Node Version Manager for Windows : https://github.com/hakobera/nvmw

@trisys3
Copy link

trisys3 commented Jan 15, 2014

If I used one of the zip files from this site, how could I get the grep.exe file from it? It seems to be the latest version, hosted right on the Git Bash site, but not included in Git Bash. I tried "configure" & that did a lot of stuff, but didn't make the exe. "make" doesn't come with git-scm.

@UltCombo
Copy link

@trisys3 You're linking to the official GNU grep, and as far as I know, GNU is Unix-compatible only. If you're running Windows, you will need a port of it - see my comment above.

@trisys3
Copy link

trisys3 commented Jan 16, 2014

OK, I guess I'll just use ezwinport's port. It's just so frustrating that Git Bash has on its site not only the latest version, but the latest dev version, and they can't think to port it over.

@Daniel-Hug
Copy link

I also get a similar error when trying to update node using the n package:

D:\Users\Daniel>npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.

D:\Users\Daniel>npm install -g n
npm http GET https://registry.npmjs.org/n
npm http 200 https://registry.npmjs.org/n
npm http GET https://registry.npmjs.org/n/-/n-1.2.1.tgz
npm http 200 https://registry.npmjs.org/n/-/n-1.2.1.tgz
D:\Users\daniel\AppData\Roaming\npm\n -> D:\Users\daniel\AppData\Roaming\npm\nod
e_modules\n\bin\n
n@1.2.1 D:\Users\daniel\AppData\Roaming\npm\node_modules\n

D:\Users\Daniel>n stable
Input file specified two times.

grep: invalid option -- o
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
cp: cannot stat `/usr/local/n/versions//*': No such file or directory

D:\Users\Daniel>

@ljharb
Copy link
Member

ljharb commented Mar 31, 2014

I'm going to close this - this is clearly a git bash issue on Windows, and not an nvm issue.

@ljharb ljharb closed this as completed Mar 31, 2014
@flcintfre
Copy link

It's a conflict with Windows overriding GNU for me... Renamed C:\Windows\grep to grep2 and problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-issue / invalid This isn't relevant to nvm, or turned out to be something unrelated. OS: windows
Projects
None yet
Development

No branches or pull requests