When running code, the first step is to invoke the compile script of the current language configuration, if enabled. Next, the run command for the selected language configuration is executed. The run command is a shell command and can be customized under Preferences ‣ Languages, or under
.When executing a run command such as python $filename
, the full path to the binary python
has not been specified, so the shell needs to search for it. The directories to be searched are listed in the PATH
environment variable, separated by colons (:
).
When invoking the run command, CodeRunner attempts to replicate the environment and PATH
that would be present if the command were invoked in the terminal. This means that before executing the run command, the shell is launched in login mode (unless this is disabled under Preferences ‣ Shell). When launched in login mode, the shell executes a number of start up scripts such as ~/.profile
, ~/.bash_profile
, and ~/.zprofile
. A common way for third-party command line applications and developer tools to make their commands available is to modify one of these files to update the PATH
variable.
To be more precise about which binary is getting invoked as part of the run command, you can specify the full path to the binary. For example, instead of python $filename
, the run command might be /usr/bin/python $filename
. If you're using a command in the terminal and believe that CodeRunner is using a different binary, you can use the shell command which <command>
in the terminal to determine the full path of the executable which would be invoked, as per the PATH
environment variable. You can then update CodeRunner's run command to include the full path to the binary.