Skip to content

Latest commit

 

History

History
129 lines (87 loc) · 5.86 KB

installation.md

File metadata and controls

129 lines (87 loc) · 5.86 KB

Installation

The easiest way to install gdenv is by using the pre-built binaries. These can be manually downloaded and configured, but automated installation scripts are provided and recommended.

Alternatively, you can install gdenv from source using the latest supported version of Go. See Install from source for more details.

Pre-built binaries (recommended)

⚠️ WARNING: It's good practice to inspect an installation script prior to execution. The scripts are included in this repository and can be reviewed prior to use.

Linux/MacOS

curl https://raw.githubusercontent.com/coffeebeats/gdenv/main/scripts/install.sh | sh

Windows

Git BASH for Windows

If you're using Git BASH for Windows follow the recommended Linux/MacOS instructions.

Powershell

NOTE: In order to run scripts in PowerShell, the execution policy must not be Restricted. Consider running the following command if you encounter UnauthorizedAccess errors when following these instructions. See Set-ExecutionPolicy documentation for details.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Invoke-WebRequest `
    -UseBasicParsing `
    -Uri "https://raw.githubusercontent.com/coffeebeats/gdenv/main/scripts/install.ps1" `
    -OutFile "./install-gdenv.ps1"; `
    &"./install-gdenv.ps1"; `
    Remove-Item "./install-gdenv.ps1"

Manual download

NOTE: The instructions below provide bash-specific commands for a Linux-based system. While these won't work in Powershell, the process will be similar.

  1. Download a prebuilt binary from the corresponding GitHub release. Set VERSION, OS, and ARCH to the desired values.

    VERSION=0.0.0 OS=linux ARCH=x86_64; \
    curl -LO https://github.com/coffeebeats/gdenv/releases/download/v$VERSION/gdenv-$VERSION-$OS-$ARCH.tar.gz
  2. Extract the downloaded archive. To customize the gdenv install location, set GDENV_HOME to the desired location (defaults to $HOME/.gdenv on Linux/MacOS).

    GDENV_HOME=$HOME/.gdenv; \
    mkdir -p $GDENV_HOME/bin && \
    tar -C $GDENV_HOME/bin -xf gdenv-$VERSION-$OS-$ARCH.tar.gz
  3. Export the GDENV_HOME environment variable and add $GDENV_HOME/bin to PATH. Add the following to your shell profile script (e.g. in .bashrc, .zshenv, .profile, or something similar).

    export GDENV_HOME="$HOME/.gdenv"
    export PATH="$GDENV_HOME/bin:$PATH"

Install from source

gdenv is a Go project and can be installed using go install. This option is not recommended as it requires having the Go toolchain installed, it's slower than downloading a prebuilt binary, and there may be instability due to using a different version of Go than it was developed with.

go install github.com/coffeebeats/gdenv/cmd/gdenv@latest
go install github.com/coffeebeats/gdenv/cmd/gdenv-shim@latest

Once gdenv and gdenv-shim are installed a few things need to be configured. Follow the instructions below based on your operating system.

Linux/MacOS

  1. Export the GDENV_HOME environment variable and add $GDENV_HOME/bin to the PATH environment variable.

    Add the following to your shell's profile script/RC file:

    export GDENV_HOME="$HOME/.gdenv"
    export PATH="$GDENV_HOME/bin:$PATH"
  2. When installing from source the gdenv-shim binary is not renamed to godot; that is only done as part of the build process for the published binaries. To resolve this and allow the godot command to route to the correct version of Godot, add a link from the installed gdenv-shim binary to godot:

    NOTE: Make sure to restart your terminal after the previous step so that any changes to $GDENV_HOME have been updated.

    test ! -z $GDENV_HOME && \
        command -v gdenv-shim >/dev/null 2>&1 && \
        ln -s $(which gdenv-shim) $GDENV_HOME/bin/godot

Windows (Powershell)

  1. Export the GDENV_HOME environment variable using the following:

    $GdEnvHomePath = "${env:LOCALAPPDATA}\gdenv" # Replace with whichever path you'd like.
    [System.Environment]::SetEnvironmentVariable("GDENV_HOME", $GdEnvHomePath, "User")
  2. Add $GDENV_HOME/bin to your PATH environment variable:

    NOTE: Make sure to restart your terminal after the previous step so that any changes to $GDENV_HOME have been updated.

    $PathParts = [System.Environment]::GetEnvironmentVariable("PATH", "User").Trim(";") -Split ";"
    $PathParts = $PathParts.where{ $_ -ne "${env:GDENV_HOME}\bin" }
    $PathParts = $PathParts + "${env:GDENV_HOME}\bin"
    
    [System.Environment]::SetEnvironmentVariable("PATH", $($PathParts -Join ";"), "User")
  3. When installing from source the gdenv-shim binary is not renamed to godot; that is only done as part of the build process for the published binaries. To resolve this and allow the godot command to route to the correct version of Godot, add a link from the installed gdenv-shim binary to godot:

    NOTE: Make sure to restart your terminal after the previous step so that any changes to $GDENV_HOME and $PATH have been updated.

    New-Item "${env:GDENV_HOME}\bin" -ItemType Directory -ea 0
    New-Item -Path "${env:GDENV_HOME}\bin\godot.exe" -ItemType SymbolicLink -Value $((Get-Command gdenv-shim).Path)

    If you encounter an error New-Item: Administrator privilege required for this operation then re-run the command in step 3 from a terminal with Administrator privileges.