skip to Main Content

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


  1. Straightforward solution

    Please, see the following references:

    The solution is:

    1. To wait for a next Visual Studio Code release with the resolved issue.
    2. To upgrade to the release.

    As per the GitHub issue comment:

    Tyriar commented 2022-09-12T12:54:25Z

    The fix for this is coming in 1.71.2, not sure on the release date currently.

    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:

    Tyriar commented 2022-09-02T19:31:19Z

    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:

    Login or Signup to reply.
  2. This may not be the most technically savvy solution, but I did this:

    1. Install gsed:

      brew install gnu-sed
      
    2. 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.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
  5. In Mac OS X with MacPorts I solved it with a symbolic link to use GNU sed:

    sudo port install gsed
    cd /opt/local/bin
    ln -s gsed sed
    
    Login or Signup to reply.
  6. change your terminal shell from bash to zsh
    it worked for me!
    steps:
    go to settings >command palette > select default profile > select zsh

    Login or Signup to reply.
  7. 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).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search