Skip to content
Julian Gonggrijp edited this page Jan 29, 2014 · 2 revisions

RED_SPIDER_ROOT is the environment variable that holds the path to the project root directory. Red Spider programs and libraries can use this variable in order to find the rest of the project and in order to check that the user has properly installed the software.

Users should always run Red Spider commands from within rsshell to ensure that the commands have access to the full Red Spider environment. Commands will often assume that this has been done.

Hackers can get the value of RED_SPIDER_ROOT from within their code. (Almost) all programming language standard libraries have a function for accessing environment variables. Usually it's called getenv after the procedure in the C library. For example, the following Python code obtains the path to the root directory and saves it in the variable rsroot:

import os
rsroot = os.getenv('RED_SPIDER_ROOT')
if RED_SPIDER_ROOT turns out to be the empty string, your program may tell the user to run setup.py and rsshell and abort.

The current value of RED_SPIDER_ROOT can also be inspected from the command line. On Windows:

echo %RED_SPIDER_ROOT%
On Mac OS X, Linux and other "unixy" systems:
echo $RED_SPIDER_ROOT

Currently RED_SPIDER_ROOT is permanently inserted into the user's environment by setup.py, so it's even available when rsshell does not run. This may change in the future. To be on the safe side, you should assume that it is only available within rsshell.

Clone this wiki locally