elalekey
elalekey

Reputation: 373

Visual Studio Code Terminal cannot find `lesspipe` command

When I want to make some commands in Visual Studio Code terminal, it prints a message like this:

command 'lesspipe' is available in the following places

This also happens with dircolors. If I want to do something with git or sudo or some other command, it won't let me.

enter image description here

The text is in spanish.

command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
command not found because <</usr/bin:/bin> is not include in path variable.

Upvotes: 1

Views: 2928

Answers (3)

Saroj
Saroj

Reputation: 1

I had the same issue and here's how you can do it:

  1. Open Visual Studio Code.

  2. In the menu, go to "File" > "Preferences" > "Settings" (or use the shortcut Ctrl + ,).

  3. Click on the "Open Settings (JSON)" icon in the top-right corner of the Settings page. This opens a JSON file where you can add custom settings.

  4. Add the following line to the JSON file:

    "terminal.integrated.env.linux": { "PATH": "/bin:/usr/bin:${env:PATH}" }

This assumes you are using a Linux environment. You might need to adjust the configuration accordingly if you use a different operating system.

  1. Save the file and close the Settings page.

Restart the VSCode or open a new terminal within the VSCode.

This configuration adds /bin and /usr/bin to the PATH variable for the integrated terminal within VSCode. It should help VSCode locate the lesspipe command.

Remember that these instructions are specific to Visual Studio Code and the integrated terminal within VSCode. If you are using a different terminal outside of VSCode, you might need to adjust the system environment variables or terminal-specific configurations.

Upvotes: 0

Syed Tufail Zada
Syed Tufail Zada

Reputation: 1

I would suggest to logout of root run

$ sudo nano /etc/environment

replace the path by

$ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr>

Upvotes: 0

Gino Mempin
Gino Mempin

Reputation: 29608

I am assuming that you configured Visual Studio Code to use the default shell on Linux:

vscode-integrated-shell

With that said and based on the error, it seems that there's something in your .bashrc (or .bash_profile) that messed up your PATH environment variable, something that removed /usr/bin and /bin from it. For example, if I put this some invalid commands at the end of my .bashrc:

/usr/bin/commandthatdoesnotexist 

When I open a Terminal on VSCode, those errors will display like this:

bash: /usr/bin/commandthatdoesnotexist: No such file or directory

I suggest you check your .bashrc. I don't know exactly what you added to it so I can't reproduce your problem. Check if you modified the PATH environment variable (did you re-define it? did you accidentally exported it incorrectly?). If you did, temporarily remove those changes.

On an actual terminal (outside of VSCode), you can try to do the following:

$ echo $PATH
# Should display something like this:
# /home/gino/bin:/home/gino/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

If PATH is not like that:

$ export PATH=$PATH:/usr/bin:/bin
$ sudo vim /etc/environment  # or sudo nano or sudo vi, whichever you use

Then edit PATH to look something like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Then try the terminal on VSCode again. If it's working now, re-check your modifications on .bashrc to see which one is causing the problem.

Upvotes: 1

Related Questions