Difference between revisions of "Programming/Git/Setting up development environment in Git Bash"

From Thalesians Wiki
(Created page with "'''Introduction''' If you are used to command line-based development, you may wish to set up your development environment within '''Git Bash''', an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience. Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands. Git Bash is included as part of the [https://git-scm.com/downlo...")
 
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:


'''Installing Anaconda'''
'''Installing Anaconda'''
Next, you need to install the Anaconda Python distribution on your system. You can download it from [https://www.anaconda.com/download here]. Once installed, '''conda''' won't be immediately available within Git Bash. Go into the directory where you installed Anaconda, then
<pre>
.../etc/profile.d/
</pre>
in that directory you will find a file called '''conda.sh'''. Add it to the end of your '''~/.bashrc''' file:
<pre>
echo ". ${PWD}/conda.sh" >> ~/.bashrc
</pre>
If the path to '''conda.sh''' contains spaces, you should use instead
<pre>
echo ". '${PWD}'/conda.sh" >> ~/.bashrc
</pre>
Close and re-open Git Bash for the changes to take effect. You may see
<pre>
WARNING: Found ~/.bashrc but no ~/bash_profile, ~/.bash_login or ~/.profile.
This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be create for you.
</pre>
That's not a problem.
Let's create a '''conda''' environment called "development":
<pre>
conda create --name development
</pre>
We then need to init '''bash''',
<pre>
conda init bash
</pre>
close and reopen Git Bash, and activate the new conda environment:
<pre>
conda activate development
</pre>
Suppose we now want to do some C or C++ development. Let's install '''m2w64-gcc''':
<pre>
conda install -c conda-forge m2w64-gcc
</pre>
We can now run
<pre>
gcc
</pre>
and
<pre>
g++
</pre>
Perhaps we also want to develop in Fortran. In this case
<pre>
conda install -c conda-forge m2w64-gcc-fortran
</pre>
Then we can run
<pre>
gfortran
</pre>
It's also useful to have Make:
<pre>
conda install -c conda-forge make
</pre>
so we can run
<pre>
make
</pre>
Ninja:
<pre>
conda install -c conda-forge ninja
</pre>
so we can run
<pre>
ninja
</pre>
Finally, CMake:
<pre>
conda install -c conda-forge cmake
</pre>
so we can run
<pre>
cmake
</pre>
At this point it may be a good idea to install some advanced software development editors, such as Emacs or Vim. Vim is available as a '''conda''' package:
<pre>
conda install -c conda-forge vim
</pre>
Then you can run
<pre>
vim
</pre>

Latest revision as of 16:16, 25 November 2023

Introduction

If you are used to command line-based development, you may wish to set up your development environment within Git Bash, an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience. Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands.

Git Bash is included as part of the Git For Windows package. Download and install Git For Windows like other Windows applications. Once downloaded, find the included .exe file and open to execute Git Bash.

Installing Anaconda

Next, you need to install the Anaconda Python distribution on your system. You can download it from here. Once installed, conda won't be immediately available within Git Bash. Go into the directory where you installed Anaconda, then

.../etc/profile.d/

in that directory you will find a file called conda.sh. Add it to the end of your ~/.bashrc file:

echo ". ${PWD}/conda.sh" >> ~/.bashrc

If the path to conda.sh contains spaces, you should use instead

echo ". '${PWD}'/conda.sh" >> ~/.bashrc

Close and re-open Git Bash for the changes to take effect. You may see

WARNING: Found ~/.bashrc but no ~/bash_profile, ~/.bash_login or ~/.profile.

This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be create for you.

That's not a problem.

Let's create a conda environment called "development":

conda create --name development

We then need to init bash,

conda init bash

close and reopen Git Bash, and activate the new conda environment:

conda activate development

Suppose we now want to do some C or C++ development. Let's install m2w64-gcc:

conda install -c conda-forge m2w64-gcc

We can now run

gcc

and

g++

Perhaps we also want to develop in Fortran. In this case

conda install -c conda-forge m2w64-gcc-fortran

Then we can run

gfortran

It's also useful to have Make:

conda install -c conda-forge make

so we can run

make

Ninja:

conda install -c conda-forge ninja

so we can run

ninja

Finally, CMake:

conda install -c conda-forge cmake

so we can run

cmake

At this point it may be a good idea to install some advanced software development editors, such as Emacs or Vim. Vim is available as a conda package:

conda install -c conda-forge vim

Then you can run

vim