Skip to content
James Reynolds edited this page Nov 30, 2022 · 12 revisions

Basics

tea is not a package manager.

tea is unified packaging infrastructure.

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?

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 be a unified packaging infrastructure. That means it will do both, but it wont replace existing tools either. tea's infrastructure is being designed so existing package managers will be able to use it.

But 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 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.

> tea +gnu.org/wget
tea: installed: ~/.tea/gnu.org/wget/v1.21.3
this is a temporary shell containing the following packages:
openssl.org@1.1.118, gnu.org/wget@1.21.3
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 () 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!

I believe we are going to need a tool to manage these though. The number of these symlinks can quickly get out of control.

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

Use Tea to Install Something

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.

tea +python.org python --version

Or

tea +python.org echo ""

Intermediate tea usage

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

Unintentionally modifying/updating packages

You probably don't want to do this!

tea +python.org pip install some_package

Or this!

tea 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.

Clone this wiki locally