# Get or change ConTeXt path for components/projects/environment

How does one get items in subdirectories or change the path that ConTeXt uses to get components, environments, and project files?

In other words, how might one set up a hypothetical directory structure like this:

``````  garden/
project.tex
env/env.tex
components/X.tex
components/Y.tex
products/X.tex
products/B.tex
``````

So that in `products/X.tex` one could load `\component components/X` (or `\component{components/x.tex}` or some working variant of those) to load the respective component. This does not seem to work, and ConTeXt logs `system > jobfiles > unknown tex file 'components/X'`.

Section 2.4 of the ConTeXt the manual states:

A file that is not available on the working directory is searched for on the parent directories.

Though that said, I note that when I use e.g. `header.tex`, put it in the `garden/` directory, and reference it from a product, the actual `header.tex` that gets loaded is `/usr/local/texlive/2014/texmf-dist/doc/latex/epslatex-fr/header.tex`.

What am I missing here?

I am using ConTeXt 0.60 (2014.05.21 22:04) from MacTeX, and running context with `context x.tex`.

Edit For what it's worth, the error seems to be from file-job.lua#L169, calling `commands.uselibrary`, and eventually (presumably) getting to `file-res.lua#L29::readfilename`, which ought to be doing the resolution.

Also, noting the Project Structure page of the Context Garden Wiki and Context Magazine 1101, which indicates that subpaths are permitted.

Also, when I run `\enabletrackers[resolvers.readfile]` I note the following is sent to the logs:

``` files > readfile > not found by backtracking: ../type-imp-loc.mkiv files > readfile > not found by backtracking: ../../type-imp-loc.mkiv files > readfile > not found by tree lookup: type-imp-loc.mkiv files > readfile > not found by backtracking: ../type-imp-loc.tex files > readfile > not found by backtracking: ../../type-imp-loc.tex files > readfile > not found by tree lookup: type-imp-loc.tex files > readfile > not found by backtracking: ../type-loc.mkiv files > readfile > not found by backtracking: ../../type-loc.mkiv files > readfile > not found by tree lookup: type-loc.mkiv files > readfile > not found by backtracking: ../type-loc.tex files > readfile > not found by backtracking: ../../type-loc.tex files > readfile > not found by tree lookup: type-loc.tex fonts > 'fallback modern-designsize rm 12pt' is loaded system > jobfiles > unknown tex file 'components/X' system > jobfiles > unknown tex file 'components/Y' ```

and with `\enabletrackers[context.trace]`:

``` cld > tex > f : 8 : \starttext cld > tex > w : - : \processfilemany{components/header.tex} cld > tex > f : 8 : \stoptext cld > tex > w : - : \dostarttextfile{components/header} system > jobfiles > unknown tex file 'components/header' cld > tex > f : 8 : \dostoptextfile ```

The `products/X.tex` is:

``````\startproduct X
\component components/X
\endproduct
``````

And `components/X.tex`:

``````\startcomponent X
\component components/X
\endcomponent
``````

(I have intentionally chosen the ambiguous `X` for both product and component since I expect to have this conflict at some point and would rather know sooner rather than later the implications.)

So it would seem that `\component` is not calling the readfile resolver mechanism for some reason.

• You can use `\usepath[...]` and `\usesubpath[...]` to set the subdirectories which context should use to search for your project files. Even when you place your files in subdirectories you have to use unique names because when you multiple files with the same only one of them is used. – Wolfgang Schuster Jul 21 '14 at 16:32
• @Metafox: That seems to work. Could you be so kind as to document the arguments to those? That would be a good answer. – Brian M. Hunt Jul 21 '14 at 16:37
• Both commands take the name of the folders (e.g. `\usepath[products,components]`) as argument and you load the files in these folders with `\component X` (or `\component[X]` when you prefer this form). – Wolfgang Schuster Jul 21 '14 at 16:42
• Another option is to compile the files from the `garden` directory using `context products/X`. Note that this will create the auxiliary files in the `garden` directory. – Aditya Jul 21 '14 at 16:48
• Thanks @Metafox - it is probably also worth noting that using `\usepath[.., ../..]` enables discrimination by subpath i.e. `\component components/X` will not retrieve `products/X`. Whereas `\usepath[..] \usesubpath[components,products]` with `\component X` is ambiguous —— TeX might end up using either the products/X or components/X. – Brian M. Hunt Jul 21 '14 at 16:50

So the problem seems to be path related as @Metafox put it and @Aditya noted. The comments to the question illuminate, but the best answers would seem to be as follows.

In `products/X.tex` and compiling from `products/`

``````\usepath[..]  % \usepath[..,../..] for subpaths
\component components/X
``````

Or alternatively if compiling from `garden/`

``````\component components/X
``````

Also, one may provide a `--path` argument to `context` i.e. `context --path ~/garden/`.

• While compiling from `products`, another option is to run `context --path=.. X`. (Depending on your setup, changing the command line call may be preferable to editing a file). – Aditya Jul 21 '14 at 20:29