Skip to content
James Reynolds edited this page Dec 3, 2022 · 12 revisions

Basics

tea works in the terminal. The instructions on this page are aimed at people who aren't developers and are new to Terminal. So it's pretty basic. And there will be a lot of examples.

If you don't know how to use the terminal, please do a web search for "unix terminal" and read a little bit before trying anything here. You should at least understand how to read paths (e.g. "~/" vs "/"), what a symlink is, how the Terminal finds commands or tools to run (the PATH variable), and what wget is.

Installing tea

If you are on Windows, you first need to install Windows Subsystem for Linux (WSL).

In the macOS or Linux terminal (Windows users need to use the WSL terminal), just type this command in.

sh <(curl https://tea.xyz)

The installer will ask if you want to create a symlink in /usr/local/bin. If you don't select yes, then a lot of the examples won't work and you'll need to specify the path to tea each time you run it. The installer will also ask if it can modify ~/.zshrc. That change is mostly for developers, but it won't hurt to say yes. Besides those 2 changes, tea doesn't change anything outside of its directory.

tea will be installed to ~/.tea.

The tea installer is located at https://tea.xyz. When that webpage is loaded by curl, it returns the installer instead of the webpage.

Alternate Installations

Here are some of the options when you install tea. For example, you can install it silently (answering yes to all the questions).

sh <(curl https://tea.xyz) -s

or

YES=1 sh <(curl https://tea.xyz)

You can specify the location of tea. By default, TEA_PREFIX is "/.tea". If you change it, remember that all examples with "/.tea" should be replaced with your prefix.

TEA_PREFIX=/opt/tea sh <(curl https://tea.xyz)

You can also download the installer.

curl -o install.sh https://tea.xyz

You can also download the tea binary for your platform.

curl 

Updating tea

To update tea, just run the same installer.

sh <(curl https://tea.xyz)

What are Package Managers?

tea is not a package manager.

tea is unified packaging infrastructure.

That means tea includes package manager functionality but it doesn't have an install, update, or uninstall commands because you use tea for more than just installing software.

There are basically 2 types of package managers: OS and source code package managers. An OS package manager installs tools that you can use in the terminal. A source code package manager installs libraries and source code files that a developer would use to create tools.

Existing OS package managers.

  • Homebrew (macOS and Linux)
  • apt (Linux)
  • Chocolatey (Windows)

Existing source code managers (these run on all platforms).

  • npm
  • pip
  • gem

tea aims to work with both os and source code. At first, the focus is on managing source code (because that same source code is going to be used to then build everything else later on down the road).

tea doesn't replace existing tools. tea's infrastructure is being designed so existing package managers will be able to use it.

Find tea packages

tea Usage

In its most basic form, Tea will install a package if needed and run a command or open a REPL with the package in the PATH.

tea +pkg

In the text above, "+pkg" should be replaced with the name of the package. Here is a real example that installs wget and opens a REPL. The REPL has tea in the PATH. which is a command that shows which command will run if you type it in the terminal. If which can't find a command, then the command isn't in the PATH.

> tea +gnu.org/wget
tea: installed: ~/.tea/gnu.org/wget/v1.21.3
this is a temporary shell containing the following packages:
[email protected], gnu.org/[email protected]
when done type: `exit'
tea ~ which wget
~/.tea/gnu.org/wget/v1.21.3/bin/wget
tea ~ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

If you don't want to run a REPL, specify a command (and optional args). Here is the basic form.

tea +pkg command [args]

And this is how we'd execute wget.

tea +gnu.org/wget wget http://example.com

You can also execute wget by specifying the path directly.

~/.tea/gnu.org/wget/v\*/bin/wget

Here's a different example. This runs the Python "Hello, World" example. Installing and running Python has never been easier.

> echo 'print("Hello, World")' | tea +python.org python
tea: installed: /opt/tea/python.org/v3.11.0
Hello, World

Here is a Python script. Use TextEdit, Notepad, or a Terminal editor to create this file. Save this code and name it "hello-world.py".

#!/usr/bin/env python

print("Hello, World")

Run it like this.

> tea +python.org hello-world.py
Hello, World

If a file ends in ".py", tea will automatically add +python.org, so you don't need to. I gave the examples above because it helps to understand what is going on behind the scenes. Run it like this.

> tea hello-world.py
Hello, World

Tea PATH

Note, tea doesn't add anything it installs to the PATH. As shown above, you can execute the command directly or use tea to run stuff. The easiest way to get the stuff you install with tea added to the path (starting with the cli v0.14.5) is to create a symlink to tea using the name of the tool you'd like.

sudo ln -s tea /usr/local/bin/wget

That will create a symlink for wget. And it just works!

You can also create these symlinks in a different directory and add that directory to the PATH.

mkdir ~/.tea_bin
ln -s /usr/local/bin/tea ~/.tea_bin/tea
ln -s tea ~/.tea_bin/wgett
export PATH="$HOME/.tea_bin:$PATH"
which wget
/Users/james/.tea_bin/wget

To permanently add that path to your shell (zsh) run this.

echo 'export PATH="$HOME/.tea_bin:$PATH"' >> ~/.zshrc

You can also create shell aliases or wrapper scripts. Here is an alias. Put this in ~/.zshrc

alias foo='tea +foo/bar foo'

Here is a shell script. Put this in /usr/local/bin

#!/bin/sh
exec tea +foo/bar foo "$@"

Install a package

Right now there is no difference between running something with Tea and installing something and running it. So if you only want to install something, then run a command that doesn't do anything.

For example, install Python if missing and run python and print it's version.

tea +python.org python --version

Or just run the echo command and print nothing.

tea +python.org echo ""

Install a specific package version

You can specify multiple packages and create a REPL with those dependencies in the PATH.

tea +invisible-island.net/ncurses +sourceware.org/bzip2 +tea.xyz/gx/cc +gnu.org/make

Specify a specific version of a package.

tea +python.org=3.10.8 python

Specify a minimum version. This will run the latest python 3.10.x.

tea +python.org^3.10.0 python

This will run the latest python 3.x.

tea +python.org^3.10 python

Do not modify the symlinks in ~/.tea/, for example.

ls -l /opt/tea/lua.org:
total 0
lrwxr-xr-x  1 u0076374  wheel    6 Dec  3 01:26 v* -> v5.4.4
lrwxr-xr-x  1 u0076374  wheel    6 Dec  3 01:26 v5 -> v5.4.4
lrwxr-xr-x  1 u0076374  wheel    6 Dec  3 01:26 v5.4 -> v5.4.4
drwxr-xr-x  7 u0076374  wheel  224 Dec  1 11:03 v5.4.4

The symlinks in those directories are for you so you can access specific versions. Changing them won't alter what version tea runs. Use the tea +pkg=version format to control what tea uses.

Upgrading

Some utilities will try to update themselves, but you shouldn't do that. Use tea to install the newer version.

Uninstalling packages

Packages are self-contained. Just remove the directory for the package.

rm -r ~/.tea/**pkg_name**

If you create symlinks, aliases, or wrapper scripts (see discussion of the path), then remove those too.

Unintentionally modifying/updating packages

You probably don't want to do this!

tea +python.org pip install some_package

Or this!

tea -X npm install -g some_package

The packages will be installed to ~/.tea/python.org/v3.11.0/lib/python3.11/site-packages and ~/.tea/npmjs.com/v9.0.1/lib/node_modules, which most likely isn't what you want.

You also don't want to do this.

tea +python.org=3.10.8 pip install --upgrade pip

It kind of defeats the purpose of having versioned installs.

Summary of steps

  • Install tea
  • Find a package that tea supports
    • The tea.xyz website lists all of the packages it supports.
    • You can also look in ~/.tea/tea.xyz/var/pantry/projects
  • Install and use the package
    • tea +pkg cmd [args]
    • Optional: symlink e.g ln -s tea /usr/local/bin/**cmd_name**
    • Optional: alias (see above)
    • Optional: wrapper shell script (see above)

Clone this wiki locally