Why is git bash behaving weird on PyCharm? - windows

I am using PyCharm 2019.3.3 (Community Edition) on Windows 8. I wanted to integrate Git bash in the PyCharm terminal. I have set the shell path in the terminal application settings of PyCharm as
C:\Program Files\Git\bin\bash.exe
The problem occurs when I activate a venv virtual ennvironment, set up using
python -m venv env
by running
source env/Scripts/activate
I think env is active as I see two parenthesis, () and typing pip freeze displays all installed packages in env. But this is accompanied with an error message that displays in the terminal
bash: basename: command not found
This same message is logged after typing commands like ls, clear which doesn't work but pip freeze and pip --version work. And when I deactivate env, ls, clear and pip stopped working displaying the mentioned error message.
All this problems do not occur in the Git bash application for Windows irrespective of whether I am in env or global environment and all commands work properly. I know I can just use Git bash instead of the integrated terminal of PyCharm but just wanted an answer to this problem.
What seems to be the problem here? Am I setting up my shell path wrongly or is this problem specific to PyCharm?

I solved this issue by disabling "Activate Virtualenv" checkbox in File -> Settings -> Tools -> Terminal
Since, pycharm documents does not show any support for 'Git Bash', that is probably the reason for this weird behaviour.
Terminal Options in Pycharm

Related

How to change the command base in Git Bash in VS Code?

I'm learning to use Git. After installation I can open a Bash terminal on VS Code (I'm using Windows if that's relevant). Right after opening a Bash terminal, this command shows up automatically (the id and path are masked for privacy):
myid#machineid MINGW64 /c/Users/...
$ source C:/ProgramData/Anaconda3/Scripts/activate base
(base)
I guess it means it's using Anaconda to run the Git command. However, it appears many CMD commands that otherwise work normally in a Windows terminal don't work. For example, I can't create a new folder. This error comes up:
$ mkdir test
bash: /c/ProgramData/Anaconda3/Library/usr/bin/mkdir: Permission denied
(base)
Similarly, commands like ls or touch just don't work. But I find pwd works. I look at /c/ProgramData/Anaconda3/Library/usr/bin and see there are a bunch of CMD command exe files in there, such as mkdir.exe, rm.exe. I also look at the Git installation directory and find a folder with similar exe commands (C:\Program Files\Git\usr\bin)
On the other hand, I can still use Git commands. So this works (after manually creating the folder test):
$ git init
Initialized empty Git repository in C:/Users/.../test/.git/
(base)
Also, if I don't use VS Code, but use a Git CMD then everything works just fine.
So the question is how I can fix it? More specifically, how can I direct Git to use Git command base in VS Code instead of depending on Anaconda base? What it currently means to me is that if I uninstall Anaconda then Git may not work in VS Code at all.

command not found after reinstalling git bash with "Windows default console window"

Before re-installing Git Bash, I was using "MinTTY as default terminal emulator". I just wanted my git bash to be colorful! Reinstall, follow this stackoverflow answer. Then when I use the same Git Bash apparently my common commands which is already installed before like:
nvm
node
npm
code
Is all gone! How do I get all of my command list back? I have python running thought, because I wrote in .bashrc alias python= winpty python. Are there any way to add those commands without adding them one by one through PATH environment variables? Or do I have to keep adding my list in .bashrc?
Thank you!
thank you for the attention.
Apparently, I was using the first CLI that is offered by the installation launcher after the installation is done. With the same CLI, I was so confused why does this CLI doesn't run my usual commands. However, turns out it can be solved by simply closing and opening a new CLI. Then everything went fine.
I sure felt so silly. Should've tried restarting it from the beginning.

How to activate a conda env automatically in VSC on windows using bash?

I've been trying all day to debug a code using Visual Studio Code without success. I have installed VSC on windows and I have installed bash (ubuntu) as well. I already put bash as a terminal default shell:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
The thing is when I run the debug, it tries to activate the env with activate myenv-name and I couldn't find how to change this instruction to source activate myenv-name.
Do you know how I can do this? any help will be appreciated. Thanks!
It's been a while since I asked this question and I got the answer finally. :)
It is simple we just have to create .bashrc file in our user folder there we can write whatever commands we need to run each time we start a terminal in vscode.
Here the command to activate a conda env:
source activate myenv_name
In case of bash: conda: command not found and you don't have admin permissions to change the paths use this command before source act...:
export PATH=$"/c/Users/UserName/AnacondaPath/Scripts":$PATH

ZSH Setup on Mac OS

Hi guys I have various problems with my ZSH shell. I installed Hyper Terminal for Mac and Oh My ZSH with a specific theme.
It works, however I have two problems:
1.) I have no internet connection, due to our corporate proxy. I tried almost everything. export http_proxy=http://my.proxy.dns:8080/ doesn't work and so on.
2.) I don't have the same environment variables as in my standard bash shell. For example when I run 'git' or 'npm' I always get zsh: command not found npm for example.
Now it seems I just need to apply my bash-config to my zsh shell.
I have for example tried setting: export PATH=$HOME/bin:/usr/local/bin:$PATH inside my .zshrc but no luck. Also source with my bashprofile doesnt seem to work.
How can I do that?

Start /usr/bin/login instead of /bin/bash in PyCharm terminal

After updating to PyCharm 2016.3 my terminal has changed.
In 2016.2 it fired up identical to iTerm or Terminal. Now I am supposed to run /usr/bin/login to achieve it, because PyCharm only invokes /bin/bash and if I change shell path to /usr/bin/login in preferences terminal will collapse right after starting. I assume this is happening because /usr/bin/login requires login and password.
I am a little bit confused and after some research can't figure out what is going under the hood and what should I do to startup shell as in iTerm. May somebody clarify this, please?
UPD: Fixed in 2016.3.2 (in my case)
This worked for me in macOS:
1) Open in PyCharm
Preferences > Tools > Terminal > Shell path
2) Replace
/bin/bash
with
/bin/sh -login -i
Source: https://www.jetbrains.com/help/pycharm/2016.3/working-with-embedded-local-terminal.html
I got this problem too, and it is quite annoying.
The best solution I found so far is to run bash -l in the Terminal of PyCharm every time I start using it.
I tried to put /bin/bash -l into PyCharm Preferences > Tools > Terminal > Shell path, but that doesn't work.
I got the same issue and this issue is common when one installs PyCharm CE from the application market like Software Center in Ubuntu. To get /bin/bash by default in PyCharm CE terminal, you should install it by using Jetbrains Toolbox for any version of PyCharm CE and Linux distro.

Resources