Skip to content

Set up developer environment

Peter Jonas edited this page Mar 22, 2022 · 11 revisions

Summary

  1. Running the commands in this guide
  2. Install a package manager
  3. Install CMake and Git
  4. Set up advanced developer environment (optional)

Running the commands in this guide

We recommend building on the Intel/AMD 64-bit (x86_64) architecture.

ARM architectures should work but Qt does not provide binaries for them so you'll need to compile Qt yourself or install it from a third party (e.g. your Linux distribution).

For information about compiling on Macs with Apple Silicon, please see Compiling on Macs with Apple Silicon.

Linux and macOS

Use your terminal of choice. The built-in Terminal application is fine.

Windows

Use PowerShell or Git Bash in Windows 10. CMD (Command Prompt) will work for most commands but requires a slightly different syntax.

Please do not use WSL (Windows Subsystem for Linux) or Windows versions prior to 10.

Install a package manager

Having a package manager enables you to install software quickly via the command line.

Linux

Congratulations, you already have a package manager! Use the following command to find out what it is called:

which apt yum dnf pacman emerge zypper | xargs -n1 basename

macOS

Please install one of these package managers:

Windows

Please install one of these package managers:

  • Chocolatey (choco) - recommended for most users
  • Scoop (scoop) - recommended for users who lack administrator privileges (but you'll need an admin to install it for you)

If you picked Chocolatey, it is recommended that you install gsudo (sudo) to enable the choco command to be used from within non-Admin prompts:

# Once from an Administrator prompt:
choco install gsudo

# In future, from non-Admin prompts:
sudo choco install [program]  # spawns UAC dialog to request permission

Scoop can be used from non-Admin prompts by default, but you might want to install gsudo anyway for use with other commands that require administrator privileges.

scoop install gsudo

Install CMake and Git

Use the command(s) corresponding to your package manager.

macOS

brew install cmake git
sudo port install cmake git

Windows

# Chocolatey (Admin prompt or sudo required)
choco install cmake --installargs ADD_CMAKE_TO_PATH=System
choco install git

# others
scoop install cmake git

Linux

sudo apt install cmake git
sudo dnf install cmake git
sudo pacmac -S cmake git

Older distributions may not provide a recent enough version of CMake. Check near the top of MuseScore's CMakeLists.txt for the minimum required version, then run:

cmake --version

If your distribution's version of CMake is too old, try installing it via Python's package manager pip instead. Make sure you remove the distribution version first.

# Remove outdated distribution CMake
sudo apt remove --purge cmake
sudo dnf erase cmake

# Install pip for your distribution
sudo apt install python3-pip
sudo dnf install python3-pip

# Install latest CMake from pip
pip3 install wheel setuptools # need these first to install binary packages like CMake
pip3 install cmake

The CMake PyPI package (the one installed via pip) is an official method of installing CMake as documented on the CMake downloads page. However, distribution maintainers may be forced to use their distribution's CMake when building a MuseScore package, so the existence of the PyPI CMake is not a valid reason to update our minimum required version prematurely (but there may be other reasons for doing so that are valid).

Set up advanced developer environment (optional)

This section is not required to compile and run MuseScore. However, it may be required if you want to run scripts in the repository that are supplementary to the build, such as scripts to generate assets, templates, translations, or other resources. It will also give you a much nicer experience on the command line!

All platforms

On all platforms, if you need to install a Python program or module (e.g. requests), use your regular package manager to install Python's own package manager pip, then use pip to install the program/module. Don't use your regular package manager to install the program/module because it may not give you the latest version, and this method of installation won't be tested as thoroughly as via pip.

# Don't do this:
sudo apt install python3-requests  # installs outdated version

# Do this instead:
sudo apt install python3-pip
pip3 install requests  # notice no 'sudo' and pip name ends with '3' to distinguish from the Python 2 version

Do the same in other languages that have package managers, such as Rust (cargo), Node (npm), and Ruby (gem).

Linux

Congratulations, you already have an advanced developer environment!

macOS

For licensing reasons, macOS only provides Bash version 3 by default. Use these commands to install the latest version:

brew install bash
which bash | sudo tee -a /etc/shells # allow Bash to run as login shell
chsh -s "$(which bash)" # optional: use Bash as your default login shell

Shell scripts often require a recent version of Bash, such as version 4 or even version 5, in order to function properly. If you need to write a script that does this, make sure it checks the Bash version before it does anything else.

#!/usr/bin/env bash

((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }

# Commands from this point on can safely use modern Bash syntax

As well as an outdated Bash, macOS also uses the BSD variants of the standard Unix tools (ls, find, grep, sed, etc.) rather than the more popular GNU variants used by Linux and Git Bash. The BSD and GNU variants are very similar, but syntax and features do vary slightly between them, so you should bear this in mind if you need to write shell scripts that are portable across platforms. It is possible to install the GNU variants of Unix tools on macOS but it is probably best to not do this because you'll end up writing shell scripts that won't work properly without them.

Windows

Now that you have installed Git, you also have access to Git Bash. This is a full Bash shell plus a core set of familiar Unix tools (ls, find, grep, sed, etc.) all compiled to work natively on Windows. You can access Git Bash from the Start Menu, and optionally use it for all subsequent commands instead of PowerShell or CMD.

Unfortunately, Git Bash comes with a terminal emulator called MinTTY which is pretty awful (almost as bad as Command Prompt!). Happily, the shiny new Windows Terminal can be configured to use Git Bash in addition to PowerShell and CMD. Simply install Windows Terminal from the Microsoft Store, then launch it and open its Settings (actually a JSON config file).

// Windows Terminal's settings.json
// Add this to the "profiles" section to enable Git Bash:
        {
            "guid": "{00000000-0000-0000-0000-000000000001}", // or make up your own GUID
            "name": "Bash",
            "commandline": "\"%UserProfile%\\scoop\\apps\\git\\current\\usr\\bin\\bash.exe\" -i -l",
            "icon": "%UserProfile%\\scoop\\apps\\git\\current\\usr\\share\\git\\git.ico",
            "startingDirectory": "%USERPROFILE%"
        }, // <-- Pay attention to commas in JSON files. They are needed between "}" and "{", but never before "}".

Modify the commandline and icon parameters as appropriate depending on where Git Bash is installed on your machine.

Clone this wiki locally