Skip to content

Command Line Usage

Sameer Nair-Desai edited this page Nov 17, 2022 · 21 revisions

Our template repository assumes that you have command line usage set up for the core tools used in our projects. This allows us to use the GSLab Make library to run multiple applications in a single build script.

To set up an application for command line usage, its executable must be added to the system environment variable PATH so that your operating system can locate it. We provide instructions on how to add an executable to PATH for Mac and Windows below.

Mac

By default, our template repository assumes the following executable names for the following applications:

application : executable
Python      : python
git-lfs     : git-lfs
LyX         : lyx
R           : Rscript
Stata       : stata-mp (will need to be updated if using a version of Stata that is not Stata-MP)

While these are the standard executable names for Mac, it is possible that they may differ on your computer. Default executable names can be updated in config_user.yaml. For further details, see the configuration files page.

Notice that the LyX installation and command line usage feature will only operate with the addition of a valid TeX distribution (i.e., MacTeX for MacOS).

To check if an application is setup for command line usage, type which <executable> into a terminal. If no path appears, then the application is not setup for command line usage. To add the executable of an application to PATH:

  1. Locate the executable for an application. For example, the executable for Stata is typically found at /Applications/Stata/StataMP.app/Contents/MacOS/statamp. (To open an .app, right click and click Show package contents.)

  2. In a terminal, from your user directory (/Users/name) run the following bash commands:

    touch .bash_profile
    nano .bash_profile
    

    touch tells your OS to create .bash_profile if one does not already exist. nano tells your OS to open .bash_profile with Nano.

  3. The Nano editor should appear in your terminal. Type in the path to the executable into the Nano editor in the following format export PATH="$PATH:path_to_executable" where path_to_executable refers to the full path of the directory containing the executable.

    For example, if your Stata executable was located in /Applications/Stata/StataMP.app/Contents/MacOS/statamp, you would want to type in the following text into the Nano editor: export PATH="$PATH:/Applications/Stata/StataMP.app/Contents/MacOS".

  4. Save and exit the Nano editor by pressing CTRL + X, then Y, then enter.

Sample .bash_profile

Below is a sample .bash_profile including the typical paths to STATA, R, LyX, and Python. The paths on your computer may differ.

export PATH="$PATH:/Applications/Stata/StataMP.app/Contents/MacOS"
export PATH="$PATH:/Applications/R.app/Contents/MacOS"
export PATH="$PATH:/Applications/Lyx.app/Contents/MacOS"

export PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"

Windows

By default, our template repository assumes the following executable names for the following applications:

application : executable
Python      : python
git-lfs     : git-lfs
LyX         : lyx
R           : Rscript
Stata       : statamp

However, these are the default executable names for Mac and therefore likely to differ on your computer. Default executable names can be updated in config_user.yaml. For further details, see the configuration files page.

Executable names for Windows will typically look like the following:

application : executable
Python      : python
git-lfs     : git-lfs
LyX         : LyX#.# (where #.# refers to the `LyX` software version number)
R           : Rscript
Stata       : stata_executable

Notice that the LyX installation and command line usage feature will only operate with the addition of a valid TeX distribution (i.e., TexLive for WindowsOS).

The line: stata_executable refers to name of your STATA executable. For example, if your STATA executable was located in C:\Program Files\Stata15\StataMP-64.exe, you would want to type in the following into your config_user.yaml: stata: StataMP-64. You would then want to add your STATA executable to PATH.

To check if an application is setup for command line usage, type where executable into a terminal. If no path appears, then the application is not setup for command line usage. To add the executable of an application to PATH:

  1. Locate the executable for an application. For example, the executable for R might be found at C:\Program Files\R\R-3.5.0\bin\x64\RScript.exe.
  2. In your start menu, search "environment". Click on Edit the system environment variables.
  3. Click on Environment Variables. You should see a panel that is labeled User Variables. In the panel, click on the variable called Path.
  4. Click on Edit. Click on New.
  1. Type in the full path of the directory containing the executable.

    For example, if your R executable was located in C:\Program Files\R\R-3.5.0\bin\x64\RScript.exe, you would want to type in the following text: C:\Program Files\R\R-3.5.0\bin\x64\

  2. Click OK.