MCPcopy
hub / github.com/rancher-sandbox/rancher-desktop

github.com/rancher-sandbox/rancher-desktop @v1.23.1 sqlite

repository ↗ · DeepWiki ↗ · release v1.23.1 ↗
3,672 symbols 11,280 edges 594 files 922 documented · 25%
README

Rancher Desktop

Ask DeepWiki

Rancher Desktop is an open-source project that brings Kubernetes and container management to the desktop. It runs on Windows, macOS and Linux. This README pertains to the development of Rancher Desktop. For user-oriented information about Rancher Desktop, please see rancherdesktop.io. For user-oriented documentation, please see docs.rancherdesktop.io.

Overview

Rancher Desktop is an Electron application that is mainly written in TypeScript. It bundles a variety of other technologies in order to provide one cohesive application. It includes a command line tool, rdctl, which is written in Go. Most developer activities, such as running a development build, building/packaging Rancher Desktop, running unit tests, and running end-to-end tests, are done through yarn scripts. Some exceptions exist, such as running BATS tests.

Setup

Windows

There are two options for building from source on Windows: with a Development VM Setup or Manual Development Environment Setup with an existing Windows installation.

Development VM Setup

  1. Download a Microsoft Windows 10 development virtual machine. All of the following steps should be done in that virtual machine.
  2. Open a PowerShell prompt (hit Windows Key + X and open Windows PowerShell).
  3. Run the automated setup script:

powershell Set-ExecutionPolicy RemoteSigned -Scope CurrentUser iwr -useb 'https://github.com/rancher-sandbox/rancher-desktop/raw/main/scripts/windows-setup.ps1' | iex

  1. Close the privileged PowerShell prompt.
  2. Ensure msbuild_path and msvs_version are configured correctly in .npmrc file. Run the following commands to set these properties:

npm config set msvs_version <visual-studio-version-number> npm config set msbuild_path <path/to/MSBuild.exe>

For example for Visual Studio 2022:

npm config set msvs_version 2022 npm config set msbuild_path "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"

If you get an error message when trying to run npm config set..., run npm config edit and then add lines like

msvs_version=2022 msbuild_path=C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe

Do not quote the values to the right side of the equal sign. The quotes aren't needed, and it's possible that some processors will treat them as literal parts of the path, and then fail. 7. Configure git to work with linux- and macos-originated files: git config --global --replace-all core.autocrlf false git config --global --replace-all core.eol lf If you find the lint:go tests are failing mysteriously, it's possible that the line-endings are incorrect.

You can now clone the repository and run yarn.

Manual Development Environment Setup

  1. Install Windows Subsystem for Linux (WSL) on your machine. Skip this step, if WSL is already installed.
  2. Open a PowerShell prompt (hit Windows Key + X and open Windows PowerShell).
  3. Install Scoop via iwr -useb get.scoop.sh | iex.
  4. Install 7zip, git, go, mingw, nvm, and unzip via scoop install 7zip git go mingw nvm python unzip. Check node version with nvm list. If node v22 is not installed or set as the current version, then install using nvm install 22 and set as current using nvm use 22.xx.xx.
  5. Install the yarn package manager via npm install --global yarn
  6. Install Visual Studio 2017 or higher. As of this writing the latest version is available at [https://visualstudio.microsoft.com/downloads/]; if that's changed, a good search engine should find it.
  7. Make sure you have the Windows SDK component installed. This Visual Studio docs describes steps to install components. The Desktop development with C++ workload needs to be selected, too.
  8. Configure git to work with linux- and macos-originated files: git config --global --replace-all core.autocrlf false git config --global --replace-all core.eol lf If you find the lint:go tests are failing mysteriously, it's possible that the line-endings are incorrect.
  9. Ensure msbuild_path and msvs_version are configured correctly in .npmrc file. Run the following commands to set these properties:

npm config set msvs_version <visual-studio-version-number> npm config set msbuild_path <path/to/MSBuild.exe>

For example for Visual Studio 2022:

npm config set msvs_version 2022 npm config set msbuild_path "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"

If you get an error message when trying to run npm config set..., run npm config edit and then add lines like

msvs_version=2022 msbuild_path=C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe

Do not quote the values to the right side of the equal sign. They aren't needed, and it's possible that some processor will treat them as literal parts of the path, and then fail.

You can now clone the repository and run yarn.

macOS

Install nvm to get Node.js and npm:

See https://github.com/nvm-sh/nvm#installing-and-updating and run the curl or wget command to install nvm.

Note that this script adds code dealing with nvm to a profile file (like ~/.bash_profile). To add access to nvm to a current shell session, you'll need to source that file.

Currently we build Rancher Desktop with Node 22. To install it, run:

nvm install 22.14

Next, you'll need to install the yarn package manager:

npm install --global yarn

You'll also need to run brew install go if you haven't installed go.

Then you can install dependencies with:

yarn

⚠️ Working on a mac with an M1 chip?

You will need to set the M1 environment variable before installing dependencies and running any npm scripts:

export M1=1 yarn

You will want to run git clean -fdx to clean out any cached assets and re-downloaded with the correct arch before running yarn if you previously installed dependencies without setting M1 first.

Linux

Ensure you have the following installed:

  • Node.js v22. Make sure you have any development packages installed. For example, on openSUSE Leap 15.6 you would need to install nodejs22 and nodejs22-devel.

  • yarn classic

  • Go 1.22 or later.

  • Dependencies described in the node-gyp docs installation. This is required to install the ffi-napi npm package. These docs mention "a proper C/C++ compiler toolchain". You can install gcc and g++ for this.

Then you can install dependencies with:

yarn

You can then run Rancher Desktop as described below. It may fail on the first run - if this happens, try doing a factory reset and re-running, which has been known to solve this issue.

Running

Once you have your dependencies installed you can run a development version of Rancher Desktop with:

yarn dev

Tests

To run the unit tests:

yarn test

To run the integration tests:

yarn test:e2e

Building

Rancher can be built from source on Windows, macOS or Linux. Cross-compilation is currently not supported. To run a build do:

yarn build
yarn package

The build output goes to dist/.

Debugging builds with the Chrome remote debugger

The Chrome remote debugger allows you to debug Electron apps using Chrome Developer Tools. You can use it to access log messages that might output to the developer console of the renderer process. This is especially helpful for getting additional debug information in production builds of Rancher Desktop.

Starting Rancher Desktop with Remote Debugging Enabled

To enable remote debugging, start Rancher Desktop with the --remote-debugging-port argument.

On Linux, start Rancher Desktop with the following command:

rancher-desktop --remote-debugging-port="8315" --remote-allow-origins=http://localhost:8315

On macOS, start Rancher Desktop with the following command:

/Applications/Rancher\ Desktop.app/Contents/MacOS/Rancher\ Desktop --remote-debugging-port="8315" --remote-allow-origins=http://localhost:8315

On Windows, start Rancher Desktop with the following command:

cd 'C:\Program Files\Rancher Desktop\'
& '.\Rancher Desktop.exe' --remote-debugging-port="8315" --remote-allow-origins=http://localhost:8315

After Rancher Desktop starts, open Chrome and navigate to http://localhost:8315/. Select the available target to start remote debugging Rancher Desktop.

image

image

Remote Debugging an Extension

To remote debug an extension, follow the same process as remote debugging a build. However, you will need to load an extension before navigating to http://localhost:8315/. Both Rancher Desktop and the loaded extension should be listed as available targets.

image

image

Debugging dev env with GoLand

The following steps have been tested with GoLand on Linux but might work for other JetBrains IDEs in a similar way.

  1. Install the Node.js plugin (via File > Settings > Plugins)

image

  1. Go to the "Run/Debug Configurations" dialog (via Run > Edit Configurations...)
  2. Add a new Node.js configuration with the following settings:
  3. Name: a name for the debug configuration, e.g. rancher desktop
  4. Node interpreter: choose your installed node interpreter, e.g. /usr/bin/node
  5. Node parameters: scripts/ts-wrapper.js scripts/dev.ts
  6. Working directory: choose the working directory of your project, e.g. ~/src/rancher-desktop

image

  1. Save the configuration
  2. You can now set a breakpoint and click "Debug 'rancher desktop'" to start debugging

image

Development Builds

Windows and macOS

Each commit triggers a GitHub Actions run that results in application bundles (.exes and .dmgs) being uploaded as artifacts. This can be useful if you want to test the latest build of Rancher Desktop as built by the build system. You can download these artifacts from the Summary page of completed package actions.

Linux

Similar to Windows and macOS, Linux builds of Rancher Desktop are made from each commit. However on Linux, only part of the process is done by GitHub Actions. The final part of it is done by Open Build Service.

There are two channels of the Rancher Desktop repositories: dev and stable. stable is the channel that most users use. It is the one that users are instructed to add in the official documentation, and the one that contains builds that are created from official releases. dev is the channel that we are interested in here: it contains builds created from the latest commit made on the main branch, and on any branches that match the format release-*. To learn how to install the development repositories, see below.

When using the dev repositories, it is important to understand the format of the versions of Rancher Desktop available from the dev repositories. The versions are in the format:

<priority>.<branch>.<commit_time>.<commit>

where:

priority is a meaningless number that exists to give versions built from the main branch priority over versions built from the release-* branches when updating.

branch is the branch name; dashes are removed due to constraints imposed by package formats.

commit_time is the UNIX timestamp of the commit used to make the build.

commit is the shortened hash of the commit used to make the build.

.deb Development Repository

You can add the repo with the following steps:

curl -s https://download.opensuse.org/repositories/isv:/Rancher:/dev/deb/Release.key | gpg --dearmor | sudo dd status=none of=/usr/share/keyrings/isv-rancher-dev-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/isv-rancher-dev-archive-keyring.gpg] https://download.opensuse.org/repositories/isv:/Rancher:/dev/deb/ ./' | sudo dd status=none of=/etc/apt/sources.list.d/isv-rancher-dev.list
sudo apt update

You can s

Extension points exported contracts — how you extend this code

VMExecutor (Interface)
(no doc) [6 implementers]
pkg/rancher-desktop/backend/backend.ts
Tracker (Interface)
Tracker is the interface that includes all the functions that are used to keep track of the port mappings plus NetTracke [3 …
src/go/guestagent/pkg/tracker/tracker.go
Dependency (Interface)
(no doc) [5 implementers]
scripts/lib/dependencies.ts
assetInfo (Interface)
* assetInfo describes information we need about one asset.
scripts/populate-update-server.ts
GitHubReleasePayload (Interface)
* Partial contents of the event payload, for a release event.
scripts/release-merge-to-main.ts
GoModule (Interface)
* The subset of `go mod edit -json` output that we care about.
scripts/lint-go.ts
K8sError (Interface)
(no doc)
background.ts
ScreenshotsOptions (Interface)
(no doc)
screenshots/Screenshots.ts

Core symbols most depended-on inside this repo

log
called by 400
pkg/rancher-desktop/utils/logging.ts
push
called by 344
pkg/rancher-desktop/backend/containerClient/auth.ts
on
called by 224
pkg/rancher-desktop/main/ipcMain.ts
resolve
called by 222
pkg/rancher-desktop/utils/latch.ts
debug
called by 221
pkg/rancher-desktop/utils/logging.ts
error
called by 192
pkg/rancher-desktop/utils/logging.ts
Run
called by 170
src/go/wsl-helper/pkg/wsl-utils/run_windows.go
Close
called by 166
src/go/guestagent/pkg/procnet/scanner_linux.go

Shape

Function 1,596
Method 1,397
Class 334
Interface 194
Struct 107
Enum 20
TypeAlias 16
FuncType 7
Route 1

Languages

TypeScript74%
Go26%
Python1%

Modules by API surface

pkg/rancher-desktop/backend/lima.ts92 symbols
scripts/dependencies/tools.ts68 symbols
pkg/rancher-desktop/backend/wsl.ts66 symbols
background.ts58 symbols
pkg/rancher-desktop/backend/mock.ts51 symbols
pkg/rancher-desktop/backend/k3sHelper.ts46 symbols
pkg/rancher-desktop/main/commandServer/httpCommandServer.ts44 symbols
pkg/rancher-desktop/backend/kube/client.ts44 symbols
pkg/rancher-desktop/store/container-engine.ts43 symbols
pkg/rancher-desktop/main/mainEvents.ts43 symbols
pkg/rancher-desktop/main/commandServer/settingsValidator.ts40 symbols
scripts/lib/dependencies.ts39 symbols

Dependencies from manifests, versioned

cyphar.com/go-pathrsv0.2.1 · 1×
dario.cat/mergov1.0.2 · 1×
github.com/AdaLogics/go-fuzz-headersv0.0.0-2023081113042 · 1×
github.com/AdamKorcz/go-118-fuzz-buildv0.0.0-2023030612354 · 1×
github.com/Masterminds/goutilsv1.1.1 · 1×
github.com/Masterminds/log-gov1.0.0 · 1×
github.com/Masterminds/semverv1.5.0 · 1×
github.com/Masterminds/semver/v3v3.5.0 · 1×
github.com/Masterminds/sprig/v3v3.3.0 · 1×
github.com/Microsoft/go-winiov0.6.2 · 1×
github.com/Microsoft/hcsshimv0.13.0 · 1×
github.com/adrg/xdgv0.5.3 · 1×

For agents

$ claude mcp add rancher-desktop \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact