Home > Mobile >  'sed: illegal option -- r usage' error in Visual Studio Code
'sed: illegal option -- r usage' error in Visual Studio Code

Time:09-05

I just updated my Visual Studio application (now 1.71.0 (Universal)) on my Mac (High Sierra), and I noticed that when I start up my terminal in VSCode, that I get this message with every command that I run:

sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

I think this has something to do with me updating VS Code, but I don't know why or how to fix it. Has anyone run into this before?

CodePudding user response:

Straightforward solution

Please, see the GitHub issues:

The solution is to wait for a next Visual Studio Code release with the resolved issue(s).

Workaround solution #1

Please, see the GitHub issue: sed -r shell integration error on OSX · Issue #159946 · microsoft/vscode · GitHub.

Please, note the workaround-related comment:

Tyriar commented yesterday

See comments in e55863c

sed -r doesn't work on OSX Catalina, I get an error at each command in the integrated terminal

Workaround for anyone hitting this is to set HISTCONTROL to one of erasedups, ignoreboth, ignoredups in your ~/.bashrc.

Workaround solution #2

The solution is to override («replace») the macOS (BSD) sed with the GNU sed.

For example, please, refer:

CodePudding user response:

This may not be the most technically savvy solution, but I did this:

  1. Install gsed

brew install gnu-sed

  1. make a symbolic link to gsed

cd /usr/local/bin

ln -s gsed sed

When VSCode fixes the issue, I will delete the symbolic link, and uninstall gsed.

  • Related