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

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.

Related

How to get the sh formatter up and running?

The goal is to set up formatting for bash scripts (.sh files). So I'm trying to play around with the .sh formatter. From the project's github quick start section; I have go installed and have pulled in the shfmt module like so: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt. But on trying to invoke the shfmt command. I'm getting the common command not found error. How do I actually use the shfmt command. My assumption is this is plug and play i.e. I don't need to actually go and fiddle around with PATHs or ENVs.
The command is installed as $HOME/go/bin/shfmt (unless GOBIN is set, then it's $GOBIN/shfmt):
$ go help install
usage: go install [-i] [build flags] [packages]
Install compiles and installs the packages named by the import paths.
Executables are installed in the directory named by the GOBIN environment
variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH
environment variable is not set.
The installation happens with a help of go install command as Peter mentioned. I would like to make a step by step that worked for me on Windows 7 machine, because I bet there are some of you who don't know anything about go language and don't even want to hear about it:
Install go language from golang.org (I used installer for Windows of course)
Download .sh formatter and unzip it somewhere
Navigate to the root directory ..\sh-master with your favourite terminal (I use GitBash or you can use cmd.exe which every Windows has by default)
Run command go install and installation should start
Once installation is done, through terminal (GitBash or cmd) navigate to $HOME/go/bin (on Windows by default it's under C:\Users\your_username\go\bin)
From here you can use the shfmt command like so shfmt -l -w yourBashScript.sh
Voila! now your bash script yourBashScript.sh is modified and formatted)

RVM's auto-detect Ruby version via repo files feature is not working in VSCode login shell terminal

RVM has a feature to detect and use the correct Ruby version based on e.g. a .ruby-version file in the repo. This requires a login shell which I have enabled in VSCode via:
"terminal.integrated.shell.linux": "bash",
"terminal.integrated.shellArgs.linux": ["--login"],
However the feature isn't working by default, I have to cd . every time I open the terminal as if it is not a login shell.
There's a similar issue about new tabs in a gnome shell: https://github.com/rvm/rvm/issues/2519
I wonder if anyone else ran into this and whether this might be an issue with VSCode or RVM?
The reason this doesn't work by default is because rvm hooks the cd command in the shell to setup the ruby/gem paths for your project and there's no cd issued to the shell by the VS Code terminal opening.
I was able to resolve this issue on my Linux system by adding the login setup as suggested in the question and then adding a simple cd . at the end of my ~/.bash_profile after the section where RVM is actually set up.
Doing this results in rvm properly adjusting the paths in the VS Code terminal.
This may be a workaround..
Add this in vs
"terminal.integrated.shellArgs.linux": [
"cd ."
],

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

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.

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.

Compiled vim from source on Mac OSX and getting 'shell returned 127' error?

On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used the same vim?
I need 7.3 for some of the features. So I set about wanting to update the terminal version. I basically cloned it using Mercurial (the perferred way according to the official site) and then did the usual to compile it. This did work and I now have 7.3 in my terminal. But, on some commands when exiting, I can this error:
/bin/bash: q: command not found
shell returned 127
Press ENTER or type command to continue
...I've tried my hardest to try and fix this problem, but trying to reinstall MacVIM, deleting the vim in my /usr/local/bin and compiling again and I just can't get rid of this annoying error.
Can anyone possibly help me? Am I doing this all wrong? ...most of the time I will be using MacVIM, but it'd be nice for me to have it in the Terminal - exactly how I'd have it on my Ubuntu servers.
Any help would be fantastic!
:!q is not :q!. This is probably not a bug.
The error message you're seeing is is most likely the result of accidentally typing :!q instead of :q!, which would be user error, not a bug. :!q shells out to run q, and your shell (bash) is not finding such a command and bails with 127. (For comparison, you might try :!true, :!false, :!vim %, to get a feel of this.)
There isn't really a “fix” for this, and ! is really useful for other purposes; maybe with more practice you'll make the typo less often. You could also try using ZQ instead of :q!; this has other disadvantages (a typo ZZ will instead save the file if it's edited, and ZQ specifically is a vim extension), but at least you see this error again.
The upshot here is basically check to make sure you typed in your commands right, I guess.
I'm not sure on the exact path, but somewhere a few folders deep into the Applications/MacVim.app folder is the vim executable that will also run in a terminal (Use the -g option to launch it in GUI mode).
You should be able to throw this in your .bashrc:
alias vim=/Applications/MacVim.app/Contents/MacOS/vim
This is the homebrew formula for vim. Try these settings for "configure" or just install homebrew and install vim from there.
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
"--enable-gui=no",
"--without-x",
"--disable-nls",
"--enable-multibyte",
"--with-tlib=ncurses",
"--enable-pythoninterp",
"--enable-rubyinterp",
"--with-features=huge"
system "make"
system "make install"

Resources