Get the Avail Source

A source distribution of Avail is available for users of Windows, Mac OS X, Linux, and other Unix systems. A source distribution is obtained by cloning the official Avail project repository. The following instructions are provided using a Unix terminal. Windows users will need to make the appropriate adjustments to dereference environment variables.

A Git client is required to clone the project repository. If you do not already have one installed, then you can obtain one here. We have noticed that the Git binaries for Mac OS X are sometimes mislinked on older versions of the operating system (< 10.9.x); if you encounter this problem, then uninstall the Git client and install Xcode to obtain a properly linked build of Git.

The Avail project repository is located at:

https://github.com/AvailLang/Avail.git

The masterbranch tracks main-line development. Assuming that git is available on your PATH, you can obtain the latest-and-greatest from master using the following command:

Installation

If you obtained a source distribution of Avail, the you have more work to do before you can start experimenting with Avail. The official installation instructions are included in the README.md file of the source distribution:

README.md is a plain text document that contains Unicodecode points in the UTF-8character encoding, so it can be read by most modern editors. As a courtesy to aging developers and system administrators, such as several of the Avail team members, it is manually line-broken to look good on an 80-column display.

If you encounter problems during installation and you discover that there is disagreement between README.md and the following instructions, then please treat README.md as gospel.

Prerequisites

Before installing Avail, you will need to make sure that you have obtained and installed the prerequisite software:

Java: You will need version 1.8, or later, of the Java Development Kit (JDK). Many modern systems already have some version of the JDK, so you should check your JDK version before obtaining and installing it from Oracle (or some other vendor). You can do so like this:

$ javac -version

And hopefully you get back something like this:

javac 1.8.0_221

Otherwise, the latest version of the Java SE Development Kit 8 can be obtained at:

Please follow any installation directions provided by the Oracle website or included with the JDK.

Please make sure that java and javac are on your PATH.

Gradle: This is the build software used to compile and install Avail. You do not need to obtain Gradle manually, as the build process will take care of this for you automatically.

Building

You will need to compile Avail using the provided Gradle wrapper. To build Avail on a Unix-based system, such as Linux, Mac OS X, Minimalist GNU for Windows (MinGW), or Windows Subsystem for Linux (WSL):

$ cd "$PROJ"
$ ./gradlew build

To build Avail on vanilla Windows:

$ cd "$PROJ"
$ .\gradlew.bat build

Where $PROJ is the location of your local copy of the Avail project repository. You should see output similar to this:

ATTENTION ==========================================================
Be sure to set AVAIL_HOME to:
$PROJ/distro
And update your path to include:
$PROJ/distro/bin
For example, a user of bash might include something like the
following in the appropriate shell config file:
export AVAIL_HOME=$PROJ/distro
export PATH=$PATH:$PROJ/distro/bin
Once your path has been updated, from any directory you can launch
the Avail workbench like this:
avail-dev
Or the Avail server like this:
avail-server
(The server is currently hard-wired to run on port 40000. This will
change at some point.)
To develop Avail code, you will also need to set AVAIL_ROOTS to a
valid module root path. If AVAIL_ROOTS is not set, then avail-dev
temporarily sets it to:
avail=$HOME/.avail/repos/avail.repo,$PROJ/distro/src/avail;\
examples=$HOME/.avail/repos/examples.repo,$PROJ/distro/src/examples
This is convenient for experimenting with Avail, but must be
extended with custom module roots as you develop your own modules.
====================================================================
BUILD SUCCESSFUL in 23s
19 actionable tasks: 19 executed

If your transcript includes BUILD SUCCESSFUL near the end, then your build is ready for use. You may, of course, move the distro subdirectory to another user-specific or even system-wide location, and then update your AVAIL_HOME and PATH variables accordingly. Hereinafter we use $INSTALL to refer to the final destination of the distro directory.

Configuring

In order to develop Avail libraries and programs, you will need to configure your environment appropriately. On Unix, this is best accomplished by updating your shell configuration file. On Windows, you can use the Control Panel to adjust the environment variables.

The following steps should be taken to prepare your environment for Avail development:

Set the AVAIL_HOME environment variable to $INSTALL. (You will need to put $INSTALL in quotation marks"(U+0022) if it contains spaces(U+0020).) The Avail workbench, avail-dev on Unix and avail-dev.bat on vanilla Windows, uses this information to locate Avail, and will not run correctly without AVAIL_HOME being set.

Update your PATH to include $INSTALL/bin. (Again, on Unix systems you will need to put $INSTALL in quotation marks if it contains spaces.) This is where avail-dev and avail-dev.bat are located. This enables your shell to find the command without the user needing to prefix its exact path or change the working directory.

Set the AVAIL_ROOTS environment variable to a valid module roots path so that Avail can find its modules, or …

… alternatively, you may start the Avail workbench without specifying AVAIL_HOME and use the Preferences… menu item to enter the module roots path, one module root at a time. Upon exiting the Avail workbench, this information is persisted for future sessions.

A module roots path is a specification of locations that contain Avail code, in either binary or source form. A module roots path comprises several module root specifications separated by semicolons;(U+003B). (On Unix systems, you will need to put each semicolon in apostrophes'(U+0027), in order to hide it from the shell's command parser.)

Each module root specification comprises a module root name, which is just a unique logical identifier, and a module root path. A module root name usually denotes a vendor or a project, and does not need to have any relationship to the file system. By convention, the module root name of the Avail standard library is avail, and the official collection of examples supported by The Avail Foundation is called examples. The Avail Foundation advises Avail developers to follow a reverse DNS name convention, like com.acme.super-neato-project, to prevent collision between module root names among several vendors and projects.

A module root path is actually a conjunction of a binary repository path and a source module path, respectively, separated by a comma,(U+002C). A binary repository path locates a binary file that contains the compiled forms of Avail source modules. A source module path locates a directory containing Avail source modules. The same binary repository path may be used for many source paths. If a binary repository path does not refer to an existing file, then avail-dev will create and populate this file as needed. A source path must always refer to an existing directory that is readable by the user running avail-dev.

If AVAIL_ROOTS is not defined, then avail-dev will use the following module
roots path by default:

This default is suitable for interacting with the Avail system as shipped by The Avail Foundation, but not for developing your own Avail modules. To develop your own Avail modules, your AVAIL_ROOTS environment variable must at least include a module root specification for the Avail standard library, and it must also include module root specifications for your own Avail projects.

Note that avail-dev.bat makes no effort to configure the environment. You must preconfigure the environment yourself, customize avail-dev.bat to suit your own needs, or use the Avail workbench to establish the module roots. (A lack of Windows expertise on the part of The Avail Foundation is responsible for this minimality; hopefully avail-dev.bat will be richer in a future release.)