cant use sudo, apt ,npm, etc in my vscode terminal even though I have Ubuntu bash installed on Windows 10 - bash

VSCode Version: 1.22
OS Version: Windows 10
explanation of issue:
I Entered something Basic Like sudo apt update or npm update inside my vscode integrated terminal and I get This Error Message:
bash: sudo: command not found
bash: npm: command not found
I Have the Ubuntu Bash installed on my windows 10 OS but inside my vscode terminal these commands dont work (even though they work inside the default terminal on my desktop).
How Can I fix this problem so I can strictly use the terminal in vscode and not a separate terminal, in order to save space on my screens?

This is explained in the documentation for VS Code (which has various options), but to avoid this being a link-only answer:
Set the "terminal.integrated.shell.windows" VS Code configuration variable to "C:\\Windows\\System32\\bash.exe" and you should be good to go.
For convenience, there's also a Select Default Shell command in the command palette which sets this for you.

Related

ModuleNotFoundError: No Module Named 'requests' VSCODE Mac OS

I am having a problem running my script in VSCode.
I have tried the following:
Reinstalling requests through pip, easy_install, and sudo pip
Importing requests directly in the Python interpreter (which worked)
This leads me to believe that VSCode isn't using the correct interpreter that actually has the package installed.
You can choose your interpreter in VS Code in several ways. One of them is by clicking the tab in the bottom toolbar (lower-left) which might say "Python 3.9.4 (64-bit)", upon which you will be able to select from a menu of choices, e.g. /usr/bin/python3 or a conda or brew installation, etc.
I think yours is python environment problem. To check whether it's python environment or not, you can use which python (or which python3 if you use python3) command in your both vscode terminal and mac terminal. If you see different python path, then your vscode is using different python environment. You can change the python interpreter in vscode to have same environment as your mac terminal.
Open Command Palette in vscode with ⇧⌘P
Type "Python: Select Interpreter"
Then, choose the same environment as your mac terminal (If you want the same one, you can choose the same python environment path as mac terminal that you get with "which python" or "which python3").
You may be able to find a solution here: ImportError: No module named requests
You haven't mentioned using different versions in your commands. It's possible you need to use pip3 instead of pip, or python3 instead of python.

Setting up React Native on Mac

I'm trying to install React Native on Mac but I'm not able to get past the first step.
npm install -g expo-cli
This seems to work but when I run the next step expo init AwesomeProject I'm getting this error.
-bash: expo: command not found
I also do not have a .npm-global folder. I'm running npm 6.13.4 on Mac OS X 10.15.2.
This might be a local environment issue.
Your computer should know where to look for the commands you're using, it's likely that your mac is not looking for the correct folder.
In order to expo command works, you must have /Users/yourUser/.npm-global/bin in your $PATH commands.
Open your global bash_profile file vim ~/.bash_profile.
add export PATH=$PATH:~/.npm-global/bin.
Save the changes, and right after in your command line:
source ~/.bash_profile
Now you can try the command again!
Important Note: .bash_profile will run only on login shells. For non-login shells, you would need to create or edit .bashrc with this line above.

Bash prompt missing from native terminal shell

I am using a machine running OSX High Sierra 10.13.6. I am not the admin on the computer, but I was granted sudo privileges to work on some of my coding projects.
Yesterday, I ran a handful of sudo commands in VSCode's integrated terminal including:
sudo pip install MySQL-connector-python
sudo pip install beautifulsoup4
At this point, I realized I would be better off installing these packages to my user, and I used commands like:
pip install --user Scrapy
I then started running into issues and was advised to run these two commands.
sudo brew upgrade python
sudo find / -name scrapy
From there, my terminal got stuck, and the prompt wouldn't execute. I recall having a few sudo commands that day that when I hit enter, would move my cursor to the following line, and not allow me to do anything but close the terminal window. After these two commands, my terminal window would not display a bash prompt. Rather, the cursor was all the way to the left of the window.
At this point, I found that my native terminal, and iTerm2 were both experiencing the same problem. I couldn't access the bash prompt, rendering my terminal useless.
Today, the VSCode integrated terminal is offering a bash prompt, but the native terminal and iTerm2 are not.
Please advise
Turns out sudo was running in the background, hanging the native terminal and iTerm. Still unclear why the VSCode terminal was letting me use bash.
Went into the activity monitor and force quit all instances of sudo. Seems to have solved the problem.

Git Bash build doesn't work from terminal in VS Code

I have a fresh install of Windows 10 - 64bit
MinGW - To install gcc
Git 2.15.1.4 (64 bit )
VSCode 1.20 (64 bit)
The command I am using is:
g++ --version
It doesn't work from using the terminal inside VSCode.
However running bash window outside of VSCode, it works fine. Anybody know any suggestions on how to fix it?
GitBash Terminal
GitBash In VSCode
Thanks,
Ciaran
Compare the PATH from your bash outside VSCode:
echo $PATH
And make sure to get the same PATH in your bash within VSCode:
export PATH=/the/path/you/see/in/the/previous/step
Once this test is working, check in your VSCode bash where your $HOME is, and modify your ~/.bashrc in order to set that PATH, as advised in Microsoft/vscode issue 24989.
The OP adds in the comments:
after leaving and coming back to it the next day. It is now working.... Must of needed a restart or something?
This is expected: if the PATH was modified first, the existing process did not inherit immediately that change. Closing/re-oppening everything would work however.

Bower Init Register requires an interactive shell error

this is what I get when I use bower init
what could be the problem??
The problem is with the terminal/console you're using to.
I ran into this same problem other day, I was using Git bash as my terminal, and trying to run this command with Node.js command prompt worked normally.
Try to use another terminal, like cmder (I really recommend this to Windows users), Node.js command prompt or even Windows cmd itself. Hope to have helped you. Best wishes!
The solution is to install GIT bash and avoid
using MinTTY and follow the documentation. Here is the solution:
Uninstall existing GIT bash Reinstall GIT bash Set up during
installation:
Select Use Git from the Windows Command Prompt
Select Checkout Windows-style, commit Unix-style line endings
Select Use Windows' default console window
Okay this works for sure -
Go to https://cygwin.com/install.html and download either the
32 or 64 bit version of Cygwin.
Run the install and install it onto one of your drives.
Run the Cygwin.bat and you will get the same command line
interface.
When you run bower init, it will work just fine. The Mintty that
comes with GIT is broken for somethings. Use the shell that comes
with Cygwin and you will be fine.
It works for me no problem. I used the 64 bit version on a Window 8 64bit OS. Good Luck!
You're most likely running C:\Program Files\Git\git-bash.exe and can instead run C:\Program Files\Git\bin\bash.exe to eliminate the issue. This avoids having to install another yet another terminal.

Resources