Setting up your Bash environment#
The following setup applies to any computer you may be using to run Bash commands (except for CodeOcean).
Note
On Windows, this will be “Git bash”. On Linux, you are usually using bash
, but check with your sysadmin if you are unsure. On MacOS, newer versions have changed the default shell to zsh
, which should work mostly the same. It is possible to use the bash
shell there as well.
Configure the openICPSR download script and Bitbucket access#
First, create a Bitbucket PAT. Keep it handy, you will need it below.
Next, find your openICPSR login (should be your NetID + @cornell.edu
) and your password.
The ICPSR password is not your NetID or your CMail/Google password!
It must be set separately, by invoking the “Forgot Password” functionality. See openICPSR authentication for more details.
Open up a VS Code window as follows:
code $HOME/.bashrc
copy the above exactly as shown. There is a “dot” before the word “
bashrc
”.
Warning
If this code shows an error, stop here, and debug!
If no VS Code windown shows, stop here, and debug.
You should now have a (new) VS Code window, either empty or with some pre-written script. If there is content, place your cursor at the very end of the edit window (you may need to scroll down).
Now, copy-paste the following code into the VS Code window, and edit the values with the appropriate replacements. Keep all the line breaks, quotes, and spaces (or absence thereof) as shown!
# env for ICPSR
export ICPSR_EMAIL=mylogin@cornell.edu
export ICPSR_PASS='supersecretpwd'
# env for Bitbucket
export P_BITBUCKET_PAT='supersecretPAT'
export P_BITBUCKET_USERNAME=bitbucketusername
where you can find your bitbutcketusername
in the Bitbucket Profile (top-right corner, gear icon, etc.).
Note
The use of single-quotes for the password ensures that special characters are correctly preserved.
This will
allow you to use the
aeagit
shortcut to download a Bitbucket repository to your workspace directly from the Bash command lineallow you to use the
tools/download_openicpsr_private.py
script to download replication packages from openICPSR from the Bash command line
Warning
On Windows, close the Git Bash window and open a new one to make the changes take effect. On Linux and MacOS, you can just run the following command in the terminal.
source $HOME/.bashrc
Verifying it works#
You should now be able to verify that the configuration setup worked, by typing the following at the terminal prompt:”
export | grep BIT
should show your Bitbucket username and PAT.
export | grep ICPSR
should show your openICPSR login and password.
Now clear the confidential information from your screen!
Just to be sure, now type
clear
Configure some convenience scripts#
We have a bunch of scripts, some of which can make your life easier. See AEADataEditor/editor-scripts. You can make these available to your Bash shell by running the following command:
If you do not yet have a $HOME/bin
directory#
Check first if you already have a $HOME/bin
directory:
ls -l $HOME/bin
If that yields an error, then you don’t have one. So run the next part:
cd $HOME
git clone https://github.com/AEADataEditor/editor-scripts bin
You should now have access to the various scripts, such as aeagit
.
If you already have a $HOME/bin
directory#
If you do have a $HOME/bin
directory, you will need to manually adjust a few more things. Contact your supervisor.
Other software dependencies#
You may need
Python
Rsync
On CCSS Cloud, Python should be installed. You may need to add rsync
only if you are a LDI Lab Admin working with CodeOcean. Installation has only been tested on a laptop and may not work on CCSS Cloud.
Installing Python is best done using winget
. From a Powershell, run these install commands:
winget install Python.Python.3.12
If you need rsync
, run the following in a Bash shell
setup-rsync.sh
Both Python and rsync should be installed. If you need a newer version of Python 3.x, check the internet…
Linux
Both Python and rsync should be installed. If not, check your version of package manager. You mean need to reference python3
because the default Python might be python2
, which won’t work.
Configuring Python defaults#
The last step you do once you have cloned your first repository.
If you are on a machine that has Python installed, run the following command (if it fails with python3
, replace with python
). You should do this once, from any recently cloned Bitbucket repository (which will contain a requirements.txt
file). You do NOT have to do it every time!
When running in Bash, this should work:
python -m pip install -r requirements.txt
While the use of python
might work, using python3
is more robust:
python3 -m pip install -r requirements.txt
Updating#
Sometimes, updates are made.
Scripts#
If you installed them in $HOME/bin
, then simply run
cd $HOME/bin
git pull
Adjust if you installed them somewhere else.
Python dependencies#
It is safe to re-run
python -m pip install -r requirements.txt
at any time.
Optional customizations#
Windows: Add Git Bash to the Windows Terminal#
It can be convenient to add the Git Bash to the Windows Terminal application that is present in Windows 10 and higher (better fonts, etc.).
Follow instructions at https://www.commandlinewizardry.com/post/how-to-add-git-bash-to-windows-terminal to do so.