Skip to content

Instantly share code, notes, and snippets.

@wangruohui
Last active August 23, 2024 12:01
Show Gist options
  • Save wangruohui/68d6f069ec71d3f88139b3e49a45467b to your computer and use it in GitHub Desktop.
Save wangruohui/68d6f069ec71d3f88139b3e49a45467b to your computer and use it in GitHub Desktop.
Fix `wget --no-config` to connect VSCode to CentOS 7

Today I failed to connect VS Code to a CentOS 7 server via SSH and found the following error message from vscode's log output.

wget: unrecognized option '--no-config' Usage: wget [OPTION]... [URL]... Try `wget --help' for more options.

The reason is that VScode needs to download an update package via wget and supply such an argument but wget on CentOS 7 is outdated to support this option.

Fortunately, VS Code respects the PATH variable of the user. So a viable solution is to create a wrapper script of wget (important: chmod +x to make it executable), and put it under ~/.local/bin which is configured in PATH in my .bashrc (important: in front of system paths). Then reload VS Code session to reconnect and it should be successful.

Codes of the wrapper:

#!/bin/bash

declare -a args

index=1
for arg in "$@"; do
    if [[ $arg == "--no-config" ]]; then
        continue
    fi
    args[$index]=$arg
    let index=index+1
done

echo "${args[@]}"
/usr/bin/wget "${args[@]}" 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment