A. N. Other
A. N. Other

Reputation: 489

Factor programming language: setting-up .factor-roots configuration

I downloaded the Factor programming language for Mac. I can now launch the command factor from the command line successfully. I read in a book covering this language (Seven More Languages in...) that, to run standalone programs I need to indicate the root paths from which Factor will search for vocabularies. I thus have to create a .factor-roots file in my home directory indicating the full paths to the root directories where I have my Factor source files, one path per line. My factor folder is in the /Applications folder. factor directory contains:

Factor.app          git-id
README.md           libfactor-ffi-test.dylib
basis               libfactor.dylib
core                license.txt
extra               misc
factor              work
factor.image

What should I exactly write in the .factor-roots file, to make it work?

Upvotes: 4

Views: 385

Answers (2)

David Enders
David Enders

Reputation: 43

There are three different ways to do this described in the docs. I've tried all three, and had some trouble with all of them, which lead me to this post.

I tried setting the FACTOR_ROOTS environment variable, but this didn't work at all. Not sure if this was an error on my part.

The other two methods are more successful.

Either create a file ~/.factor-roots (loaded at Factor startup) and add the path to your vocabulary root (without quotation marks).

Or create a file ~/.factor-rc (also loaded at Factor startup but can contain any code you'd like to call when Factor starts) and pass in your vocabulary root path as a parameter to the add-vocab-root word. My ~/.factor-rc contains the following:

USE: editors EDITOR: editors.visual-studio-code
USE: vocabs.loader
"/path/to/your/vocabulary/root" add-vocab-root

The vocabs.loader vocabulary is necessary to call add-vocab-root.

It took me a while to figure out that these two files need to be located in the home directory, not in the root of the Factor source.

Upvotes: 2

A. N. Other
A. N. Other

Reputation: 489

SOLVED: I have to write into the .factor-roots file the path to the directory into which I write my standalone programs, not the path to the Factor installation directory.

Upvotes: 5

Related Questions