Appendix F: Installing the Cairo binaries
If you want to have access to the Cairo binaries, for anything that you could not achieve by purely using Scarb you can install them by following the instructions below.
El primer paso es instalar Cairo. Descargaremos Cairo manualmente, utilizando el repositorio de Cairo o un script de instalación. Necesitará una conexión a Internet para la descarga.
Prerequisites
Primero deberá tener Rust y Git instalados.
# Install stable Rust
rustup override set stable && rustup update
Install Git.
Installing Cairo with a Script (Installer by Fran)
Install
If you wish to install a specific release of Cairo rather than the latest head, set the CAIRO_GIT_TAG
environment variable (e.g. export CAIRO_GIT_TAG=v2.2.0
).
curl -L https://github.com/franalgaba/cairo-installer/raw/main/bin/cairo-installer | bash
Tras la instalación, sigue estas instrucciones para configurar tu entorno shell.
Update
rm -fr ~/.cairo
curl -L https://github.com/franalgaba/cairo-installer/raw/main/bin/cairo-installer | bash
Uninstall
Cairo se instala dentro de $CAIRO_ROOT
(por defecto: ~/.cairo). Para desinstalarlo, basta con eliminarlo:
rm -fr ~/.cairo
luego elimina estas tres líneas de .bashrc:
export PATH="$HOME/.cairo/target/release:$PATH"
y, por último, reinicia tu shell:
exec $SHELL
Set up your shell environment for Cairo
- Define environment variable
CAIRO_ROOT
to point to the path where Cairo will store its data.$HOME/.cairo
is the default. If you installed Cairo via Git checkout, we recommend to set it to the same location as where you cloned it. - Add the
cairo-*
executables to yourPATH
if it's not already there
La siguiente configuración debería funcionar para la gran mayoría de usuarios en casos de uso comunes.
-
For bash:
Stock Bash startup files vary widely between distributions in which of them source which, under what circumstances, in what order and what additional configuration they perform. As such, the most reliable way to get Cairo in all environments is to append Cairo configuration commands to both
.bashrc
(for interactive shells) and the profile file that Bash would use (for login shells).First, add the commands to
~/.bashrc
by running the following in your terminal:echo 'export CAIRO_ROOT="$HOME/.cairo"' >> ~/.bashrc echo 'command -v cairo-compile >/dev/null || export PATH="$CAIRO_ROOT/target/release:$PATH"' >> ~/.bashrc
Then, if you have
~/.profile
,~/.bash_profile
or~/.bash_login
, add the commands there as well. If you have none of these, add them to~/.profile
.-
to add to
~/.profile
:echo 'export CAIRO_ROOT="$HOME/.cairo"' >> ~/.profile echo 'command -v cairo-compile >/dev/null || export PATH="$CAIRO_ROOT/target/release:$PATH"' >> ~/.profile
-
to add to
~/.bash_profile
:echo 'export CAIRO_ROOT="$HOME/.cairo"' >> ~/.bash_profile echo 'command -v cairo-compile >/dev/null || export PATH="$CAIRO_ROOT/target/release:$PATH"' >> ~/.bash_profile
-
-
For Zsh:
echo 'export CAIRO_ROOT="$HOME/.cairo"' >> ~/.zshrc echo 'command -v cairo-compile >/dev/null || export PATH="$CAIRO_ROOT/target/release:$PATH"' >> ~/.zshrc
If you wish to get Cairo in non-interactive login shells as well, also add the commands to
~/.zprofile
or~/.zlogin
. -
For Fish shell:
If you have Fish 3.2.0 or newer, execute this interactively:
set -Ux CAIRO_ROOT $HOME/.cairo fish_add_path $CAIRO_ROOT/target/release
Otherwise, execute the snippet below:
set -Ux CAIRO_ROOT $HOME/.cairo set -U fish_user_paths $CAIRO_ROOT/target/release $fish_user_paths
In MacOS, you might also want to install Fig which provides alternative shell completions for many command line tools with an IDE-like popup interface in the terminal window. (Note that their completions are independent from Cairo's codebase so they might be slightly out of sync for bleeding-edge interface changes.)
Restart your shell
para que los cambios en el PATH
surtan efecto.
exec "$SHELL"
Installing Cairo Manually (Guide by Abdel)
Step 1: Install Cairo 1.0
Si utiliza un sistema Linux x86 y puede utilizar el binario de lanzamiento, descargue Cairo aquí:https://github.com/starkware-libs/cairo/releases.
Para todos los demás, recomendamos compilar Cairo desde el código fuente de la siguiente manera:
# Start by defining environment variable CAIRO_ROOT
export CAIRO_ROOT="${HOME}/.cairo"
# Create .cairo folder if it doesn't exist yet
mkdir $CAIRO_ROOT
# Clone the Cairo compiler in $CAIRO_ROOT (default root)
cd $CAIRO_ROOT && git clone git@github.com:starkware-libs/cairo.git .
# OPTIONAL/RECOMMENDED: If you want to install a specific version of the compiler
# Fetch all tags (versions)
git fetch --all --tags
# View tags (you can also do this in the cairo compiler repository)
git describe --tags `git rev-list --tags`
# Checkout the version you want
git checkout tags/v2.2.0
# Generate release binaries
cargo build --all --release
.
NOTA: Mantener Cairo actualizado
Now that your Cairo compiler is in a cloned repository, all you will need to do is pull the latest changes and rebuild as follows:
cd $CAIRO_ROOT && git fetch && git pull && cargo build --all --release
Step 2: Add Cairo 1.0 executables to your path
export PATH="$CAIRO_ROOT/target/release:$PATH"
**NOTA: Si instala desde un binario Linux, adapte la ruta de destino en consecuencia
Step 3: Setup Language Server
VS Code Extension
- If you have the previous Cairo 0 extension installed, you can disable/uninstall it.
- Install the Cairo 1 extension for proper syntax highlighting and code navigation. You can find the link to the extension here, or just search for "Cairo 1.0" in the VS Code marketplace.
- The extension will work out of the box once you will have Scarb installed.
Cairo Language Server without Scarb
If you don't want to depend on Scarb, you can still use the Cairo Language Server with the compiler binary.
From Step 1, the cairo-language-server
binary should be built and executing this command will copy its path into your clipboard.
which cairo-language-server | pbcopy
Actualiza la cairo1.languageServerPath
de la extensión Cairo 1.0 pegando la ruta.