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?
7
Answers
Straightforward solution
Please, see the following references:
The solution is:
As per the GitHub issue comment:
Available release:
1.71.2
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:
Workaround solution #2
The solution is to override («replace») the macOS (BSD)
sed
with the GNUsed
.For example, please, refer:
Question. How do I fix "sed: illegal option — r" in macOS Sierra Android build? – Stack Overflow.
Question. macos – How to use GNU sed on Mac OS 10.10+, ‘brew install –default-names’ no longer supported – Stack Overflow.
This may not be the most technically savvy solution, but I did this:
Install
gsed
:Make a symbolic link to
gsed
:When VSCode fixes the issue, I will delete the symbolic link, and uninstall
gsed
.Im using Catalina and solved this problem with downgrading to v1.70 universal
https://code.visualstudio.com/updates/v1_70
First sync everything, change the update method to manual and simply delete the VSCode and install v1.70. Everything you added (extensions, icons etc) comes back immediately.
previously, I’m working with macOS Catalina 10.15.7 and VSCode 1.71. I got the same bug when I ran any commands on the latest version of VSCode.
as my temporary solution, I don’t use the latest version and choose the older version of VSCode (now I’m using version 1.69.1. you can use version 1.70 or another version excluding 1.71). and it works on me :).
if you using macOS and want another solution, you can change the shell in your terminal from bash to zsh. it works on me too.
In Mac OS X with MacPorts I solved it with a symbolic link to use GNU sed:
change your terminal shell from bash to zsh
it worked for me!
steps:
go to settings >command palette > select default profile > select zsh
If you’re more generally trying to write a
sed
command and receiving this error on macOS, you can replace the-r
flag with a-E
flag in your command (even though the manual does state that-r
is a valid synonym).