CINXE.COM
Compiling Bazel from Source
<!doctype html> <html lang="en" dir="ltr"> <head> <meta name="google-signin-client-id" content="157101835696-ooapojlodmuabs2do2vuhhnf90bccmoi.apps.googleusercontent.com"> <meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award"> <meta property="og:site_name" content="Bazel"> <meta property="og:type" content="website"><meta name="theme-color" content="#0c713a"><meta charset="utf-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="manifest" href="/_pwa/bazel/manifest.json" crossorigin="use-credentials"> <link rel="preconnect" href="//www.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.googleapis.com" crossorigin> <link rel="preconnect" href="//apis.google.com" crossorigin> <link rel="preconnect" href="//www.google-analytics.com" crossorigin><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"> <link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined&display=block"><link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/css/app.css"> <link rel="shortcut icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/favicon-prod.png"> <link rel="apple-touch-icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png"><link rel="canonical" href="https://bazel.build/versions/6.5.0/install/compile-source"><link rel="search" type="application/opensearchdescription+xml" title="Bazel" href="https://bazel.build/s/opensearch.xml"> <link rel="alternate" hreflang="en" href="https://bazel.build/versions/6.5.0/install/compile-source" /><link rel="alternate" hreflang="x-default" href="https://bazel.build/versions/6.5.0/install/compile-source" /><link rel="alternate" hreflang="zh-Hans" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=zh-cn" /><link rel="alternate" hreflang="zh-Hant" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=zh-tw" /><link rel="alternate" hreflang="hi" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=hi" /><link rel="alternate" hreflang="id" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=id" /><link rel="alternate" hreflang="ja" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=ja" /><link rel="alternate" hreflang="ko" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=ko" /><link rel="alternate" hreflang="pt-BR" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=pt-br" /><link rel="alternate" hreflang="es-419" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=es-419" /><link rel="alternate" hreflang="th" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=th" /><link rel="alternate" hreflang="tr" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=tr" /><link rel="alternate" hreflang="vi" href="https://bazel.build/versions/6.5.0/install/compile-source?hl=vi" /><link rel="alternate" hreflang="en-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source" /><link rel="alternate" hreflang="x-default" href="https://bazel.google.cn/versions/6.5.0/install/compile-source" /><link rel="alternate" hreflang="zh-Hans-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=zh-cn" /><link rel="alternate" hreflang="zh-Hant-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=zh-tw" /><link rel="alternate" hreflang="hi-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=hi" /><link rel="alternate" hreflang="id-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=id" /><link rel="alternate" hreflang="ja-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=ja" /><link rel="alternate" hreflang="ko-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=ko" /><link rel="alternate" hreflang="pt-BR-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=pt-br" /><link rel="alternate" hreflang="es-419-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=es-419" /><link rel="alternate" hreflang="th-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=th" /><link rel="alternate" hreflang="tr-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=tr" /><link rel="alternate" hreflang="vi-cn" href="https://bazel.google.cn/versions/6.5.0/install/compile-source?hl=vi" /><title>Compiling Bazel from Source</title> <meta property="og:title" content="Compiling Bazel from Source"><meta property="og:url" content="https://bazel.build/versions/6.5.0/install/compile-source"><meta property="og:locale" content="en"><script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "headline": "Compiling Bazel from Source" } </script> <link rel="stylesheet" href="/extras.css"></head> <body class="" template="page" theme="bazel-theme" type="article" layout="docs" display-toc pending> <devsite-progress type="indeterminate" id="app-progress"></devsite-progress> <section class="devsite-wrapper"> <devsite-cookie-notification-bar></devsite-cookie-notification-bar><devsite-header role="banner"> <div class="devsite-header--inner nocontent"> <div class="devsite-top-logo-row-wrapper-wrapper"> <div class="devsite-top-logo-row-wrapper"> <div class="devsite-top-logo-row"> <button type="button" id="devsite-hamburger-menu" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Navigation menu button" visually-hidden aria-label="Open menu"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="bazel" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/lockup.svg" class="devsite-site-logo" alt="Bazel"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> </li> </ul> </span> </div> <div class="devsite-top-logo-row-middle"> <div class="devsite-header-upper-tabs"> <devsite-tabs class="upper-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Upper tabs"> <tab > <a href="https://bazel.build/versions/6.5.0/about" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/about" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - about bazel" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: About Bazel" track-name="about bazel" > About Bazel </a> </tab> <tab class="devsite-active"> <a href="https://bazel.build/versions/6.5.0/start" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/start" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - getting started" track-metadata-module="primary nav" aria-label="Getting started, selected" data-category="Site-Wide Custom Events" data-label="Tab: Getting started" track-name="getting started" > Getting started </a> </tab> <tab > <a href="https://bazel.build/versions/6.5.0/docs" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/docs" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - user guide" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: User guide" track-name="user guide" > User guide </a> </tab> <tab > <a href="https://bazel.build/versions/6.5.0/reference" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/reference" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - reference" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Reference" track-name="reference" > Reference </a> </tab> <tab > <a href="https://bazel.build/versions/6.5.0/extending" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/extending" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - extending" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Extending" track-name="extending" > Extending </a> </tab> <tab > <a href="https://bazel.build/versions/6.5.0/community" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/community" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" > Community </a> </tab> <tab class="devsite-dropdown "> <a href="https://bazel.build/versions" track-metadata-eventdetail="https://bazel.build/versions" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - versioned docs" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" > Versioned docs </a> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Versioned docs" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions" track-metadata-position="nav - versioned docs" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.4.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.4.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.4 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.3.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.3.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.3 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.2.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.2.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.2 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.1.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.1.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.1 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/7.0.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/7.0.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 7.0 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions/6.5.0" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions/6.5.0" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 6.5 </div> </a> </li> <li class="devsite-nav-item"> <a href="https://docs.bazel.build/versions/5.4.1/bazel-overview.html" track-type="nav" track-metadata-eventdetail="https://docs.bazel.build/versions/5.4.1/bazel-overview.html" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> 5.4.1 </div> </a> </li> </ul> </div> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"> <a href="https://bazel.build/" track-type="nav" track-metadata-eventdetail="https://bazel.build/" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> Nightly </div> </a> </li> <li class="devsite-nav-item"> <a href="https://bazel.build/versions" track-type="nav" track-metadata-eventdetail="https://bazel.build/versions" track-metadata-position="nav - versioned docs" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> More… </div> </a> </li> </ul> </div> </div> </div> </tab> </nav> </devsite-tabs> </div> <devsite-search enable-signin enable-search enable-suggestions enable-query-completion project-name="Bazel" tenant-name="Bazel" > <form class="devsite-search-form" action="https://bazel.build/s/results" method="GET"> <div class="devsite-search-container"> <button type="button" search-open class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Open search"></button> <div class="devsite-searchbox"> <input aria-activedescendant="" aria-autocomplete="list" aria-label="Search" aria-expanded="false" aria-haspopup="listbox" autocomplete="off" class="devsite-search-field devsite-search-query" name="q" placeholder="Search" role="combobox" type="text" value="" > <div class="devsite-search-image material-icons" aria-hidden="true"> </div> <div class="devsite-search-shortcut-icon-container" aria-hidden="true"> <kbd class="devsite-search-shortcut-icon">/</kbd> </div> </div> </div> </form> <button type="button" search-close class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Close search"></button> </devsite-search> </div> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> <a class="devsite-header-link devsite-top-button button gc-analytics-event" href="//github.com/bazelbuild/bazel/" data-category="Site-Wide Custom Events" data-label="Site header link" > GitHub </a> <devsite-user enable-profiles id="devsite-user"> <span class="button devsite-top-button" aria-hidden="true" visually-hidden>Sign in</span> </devsite-user> </div> </div> </div> <div class="devsite-collapsible-section "> <div class="devsite-header-background"> <div class="devsite-product-id-row" > <div class="devsite-product-description-row"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> <a href="https://bazel.build/versions/6.5.0/start" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Lower Header" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="" > Get started with Bazel quickly </a> </li> </ul> </div> </div> <div class="devsite-doc-set-nav-row"> <devsite-tabs class="lower-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Lower tabs"> <tab class="devsite-active"> <a href="https://bazel.build/versions/6.5.0/install" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/install" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - install" track-metadata-module="primary nav" aria-label="Install, selected" data-category="Site-Wide Custom Events" data-label="Tab: Install" track-name="install" > Install </a> </tab> <tab > <a href="https://bazel.build/versions/6.5.0/start/cpp" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/start/cpp" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - first build tutorials" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: First build tutorials" track-name="first build tutorials" > First build tutorials </a> </tab> <tab > <a href="https://bazel.build/versions/6.5.0/concepts/build-ref" track-metadata-eventdetail="https://bazel.build/versions/6.5.0/concepts/build-ref" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - concepts" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Concepts" track-name="concepts" > Concepts </a> </tab> </nav> </devsite-tabs> </div> </div> </div> </div> </devsite-header> <devsite-book-nav scrollbars > <div class="devsite-book-nav-filter" > <span class="filter-list-icon material-icons" aria-hidden="true"></span> <input type="text" placeholder="Filter" aria-label="Type to filter" role="searchbox"> <span class="filter-clear-button hidden" data-title="Clear filter" aria-label="Clear filter" role="button" tabindex="0"></span> </div> <nav class="devsite-book-nav devsite-nav nocontent" aria-label="Side menu"> <div class="devsite-mobile-header"> <button type="button" id="devsite-close-nav" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Close navigation" aria-label="Close navigation"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="bazel" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <img src="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/lockup.svg" class="devsite-site-logo" alt="Bazel"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item "> </li> </ul> </span> </div> </div> <div class="devsite-book-nav-wrapper"> <div class="devsite-mobile-nav-top"> <ul class="devsite-nav-list"> <li class="devsite-nav-item"> <a href="/versions/6.5.0/about" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: About Bazel" track-name="about bazel" data-category="Site-Wide Custom Events" data-label="Responsive Tab: About Bazel" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > About Bazel </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/start" class="devsite-nav-title gc-analytics-event devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Getting started" track-name="getting started" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Getting started" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Getting started </span> </a> <ul class="devsite-nav-responsive-tabs"> <li class="devsite-nav-item"> <a href="/versions/6.5.0/install" class="devsite-nav-title gc-analytics-event devsite-nav-has-children devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Install" track-name="install" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Install" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip menu="_book"> Install </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="_book"> </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/start/cpp" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: First build tutorials" track-name="first build tutorials" data-category="Site-Wide Custom Events" data-label="Responsive Tab: First build tutorials" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > First build tutorials </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/concepts/build-ref" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Concepts" track-name="concepts" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Concepts" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Concepts </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> </ul> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/docs" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: User guide" track-name="user guide" data-category="Site-Wide Custom Events" data-label="Responsive Tab: User guide" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > User guide </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/reference" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Reference" track-name="reference" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Reference" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Reference </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/extending" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Extending" track-name="extending" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Extending" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Extending </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0/community" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Community" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Community </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Versioned docs" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Versioned docs </span> </a> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Versioned docs" track-name="versioned docs" > <span class="devsite-nav-text" tooltip menu="Versioned docs"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Versioned docs"> </span> </span> </li> </ul> </li> <li class="devsite-nav-item"> <a href="//github.com/bazelbuild/bazel/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: GitHub" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > GitHub </span> </a> </li> </ul> </div> <div class="devsite-mobile-nav-bottom"> <ul class="devsite-nav-list" menu="_book"> <li class="devsite-nav-item"><a href="/versions/6.5.0/install" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/bazelisk" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/bazelisk" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/bazelisk" ><span class="devsite-nav-text" tooltip>Install with Bazelisk</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/os-x" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/os-x" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/os-x" ><span class="devsite-nav-text" tooltip>macOS</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/windows" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/windows" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/windows" ><span class="devsite-nav-text" tooltip>Windows</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/redhat" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/redhat" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/redhat" ><span class="devsite-nav-text" tooltip>Fedora/CentOS</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/ubuntu" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/ubuntu" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/ubuntu" ><span class="devsite-nav-text" tooltip>Ubuntu</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/suse" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/suse" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/suse" ><span class="devsite-nav-text" tooltip>openSUSE</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/docker-container" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/docker-container" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/docker-container" ><span class="devsite-nav-text" tooltip>Try Bazel in a Docker container</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/compile-source" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/compile-source" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/compile-source" ><span class="devsite-nav-text" tooltip>Compile from source</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/completion" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/completion" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/completion" ><span class="devsite-nav-text" tooltip>Command-line completion</span></a></li> <li class="devsite-nav-item"><a href="/versions/6.5.0/install/ide" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /versions/6.5.0/install/ide" track-type="bookNav" track-name="click" track-metadata-eventdetail="/versions/6.5.0/install/ide" ><span class="devsite-nav-text" tooltip>Integrate with IDEs</span></a></li> </ul> <ul class="devsite-nav-list" menu="Versioned docs" aria-label="Side menu" hidden> <li class="devsite-nav-item"> <a href="/versions/7.4.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.4" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.4 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.3.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.3" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.3 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.2.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.2" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.2 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.1.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.1" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.1 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/7.0.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 7.0" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 7.0 </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions/6.5.0" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 6.5" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 6.5 </span> </a> </li> <li class="devsite-nav-item"> <a href="https://docs.bazel.build/versions/5.4.1/bazel-overview.html" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: 5.4.1" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > 5.4.1 </span> </a> </li> <li class="devsite-nav-item"> <a href="/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Nightly" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Nightly </span> </a> </li> <li class="devsite-nav-item"> <a href="/versions" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: More…" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > More… </span> </a> </li> </ul> </div> </div> </nav> </devsite-book-nav> <section id="gc-wrapper"> <main role="main" class="devsite-main-content" has-book-nav has-sidebar > <div class="devsite-sidebar"> <div class="devsite-sidebar-content"> <devsite-toc class="devsite-nav" role="navigation" aria-label="On this page" depth="2" scrollbars ></devsite-toc> <devsite-recommendations-sidebar class="nocontent devsite-nav"> </devsite-recommendations-sidebar> </div> </div> <devsite-content> <article class="devsite-article"> <div class="devsite-article-meta nocontent" role="navigation"> <ul class="devsite-breadcrumb-list" aria-label="Breadcrumb"> <li class="devsite-breadcrumb-item "> <a href="https://bazel.build/" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="Bazel" > Bazel </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://bazel.build/versions/6.5.0/start" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail="" > Getting started </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://bazel.build/versions/6.5.0/install" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="3" track-type="globalNav" track-name="breadcrumb" track-metadata-position="3" track-metadata-eventdetail="" > Install </a> </li> </ul> <devsite-thumb-rating position="header"> </devsite-thumb-rating> </div> <devsite-feedback position="header" project-name="Bazel" product-id="5052038" bucket="https-bazel-build" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="header" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png" > <button> Send feedback </button> </devsite-feedback> <h1 class="devsite-page-title" tabindex="-1"> Compiling Bazel from Source </h1> <devsite-feature-tooltip ack-key="AckCollectionsBookmarkTooltipDismiss" analytics-category="Site-Wide Custom Events" analytics-action-show="Callout Profile displayed" analytics-action-close="Callout Profile dismissed" analytics-label="Create Collection Callout" class="devsite-page-bookmark-tooltip nocontent" dismiss-button="true" id="devsite-collections-dropdown" dismiss-button-text="Dismiss" close-button-text="Got it"> <devsite-bookmark></devsite-bookmark> <span slot="popout-heading"> Stay organized with collections </span> <span slot="popout-contents"> Save and categorize content based on your preferences. </span> </devsite-feature-tooltip> <div class="devsite-page-title-meta"><devsite-view-release-notes></devsite-view-release-notes></div> <devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded > </devsite-toc> <div class="devsite-article-body clearfix "> <a class="button button-with-icon" href="https://github.com/bazelbuild/bazel/issues/new?title=%5Bbazel.build%5D+Problem+with+/versions/6.5.0/install/compile-source&template=doc_issue.yml&link=https%3A%2F%2Fbazel.build/versions/6.5.0/install/compile-source" target="_blank"> Report an issue<span class="material-icons icon-after" aria-hidden="true" translate="no">open_in_new</span> </a> <a class="button button-with-icon" href="https://github.com/bazelbuild/bazel/tree/master/site/en/versions/6.5.0/install/compile-source.md" target="_blank"> View source<span class="material-icons icon-after" aria-hidden="true" translate="no">open_in_new</span> </a> <span style="float: right; line-height: 36px"> <a href="/install/compile-source">Nightly</a> <!-- The lines below are updated by //scripts/docs:gen_new_toc --> <!-- BEGIN_VERSION_INDICATOR --> · <a href="/versions/7.4.0/install/compile-source">7.4</a> . <a href="/versions/7.3.0/install/compile-source">7.3</a> · <a href="/versions/7.2.0/install/compile-source">7.2</a> · <a href="/versions/7.1.0/install/compile-source">7.1</a> · <a href="/versions/7.0.0/install/compile-source">7.0</a> · <strong>6.5</strong> <!-- END_VERSION_INDICATOR --> </span> <p/> <p>This page describes how to install Bazel from source and provides troubleshooting tips for common issues.</p> <p>To build Bazel from source, you can do one of the following:</p> <ul> <li><p>Build it <a href="#build-bazel-using-bazel">using an existing Bazel binary</a></p></li> <li><p>Build it <a href="#bootstrap-bazel">without an existing Bazel binary</a> which is known as <em>bootstrapping</em>.</p></li> </ul> <h2 id="build-bazel-using-bazel" data-text="Build Bazel using Bazel" tabindex="-1">Build Bazel using Bazel</h2> <h3 id="summary" data-text="Summary" tabindex="-1">Summary</h3> <ol> <li><p>Get the latest Bazel release from the <a href="https://github.com/bazelbuild/bazel/releases" class="external">GitHub release page</a> or with <a href="https://github.com/bazelbuild/bazelisk" class="external">Bazelisk</a>.</p></li> <li><p><a href="https://github.com/bazelbuild/bazel/archive/master.zip" class="external">Download Bazel's sources from GitHub</a> and extract somewhere. Alternatively you can git clone the source tree from https://github.com/bazelbuild/bazel</p></li> <li><p>Install the same prerequisites as for bootstrapping (see <a href="#bootstrap-unix-prereq">for Unix-like systems</a> or <a href="#bootstrap-windows-prereq">for Windows</a>)</p></li> <li><p>Build a development build of Bazel using Bazel: <code translate="no" dir="ltr">bazel build //src:bazel-dev</code> (or <code translate="no" dir="ltr">bazel build //src:bazel-dev.exe</code> on Windows)</p></li> <li><p>The resulting binary is at <code translate="no" dir="ltr">bazel-bin/src/bazel-dev</code> (or <code translate="no" dir="ltr">bazel-bin\src\bazel-dev.exe</code> on Windows). You can copy it wherever you like and use immediately without further installation.</p></li> </ol> <p>Detailed instructions follow below.</p> <h3 id="build-bazel-install-bazel" data-text="Step 1: Get the latest Bazel release" tabindex="-1">Step 1: Get the latest Bazel release</h3> <p><strong>Goal</strong>: Install or download a release version of Bazel. Make sure you can run it by typing <code translate="no" dir="ltr">bazel</code> in a terminal.</p> <p><strong>Reason</strong>: To build Bazel from a GitHub source tree, you need a pre-existing Bazel binary. You can install one from a package manager or download one from GitHub. See <a href="/versions/6.5.0/install">Installing Bazel</a>. (Or you can <a href="#bootstrap-bazel">build from scratch (bootstrap)</a>.)</p> <p><strong>Troubleshooting</strong>:</p> <ul> <li><p>If you cannot run Bazel by typing <code translate="no" dir="ltr">bazel</code> in a terminal:</p> <ul> <li><p>Maybe your Bazel binary's directory is not on the PATH.</p> <p>This is not a big problem. Instead of typing <code translate="no" dir="ltr">bazel</code>, you will need to type the full path.</p></li> <li><p>Maybe the Bazel binary itself is not called <code translate="no" dir="ltr">bazel</code> (on Unixes) or <code translate="no" dir="ltr">bazel.exe</code> (on Windows).</p> <p>This is not a big problem. You can either rename the binary, or type the binary's name instead of <code translate="no" dir="ltr">bazel</code>.</p></li> <li><p>Maybe the binary is not executable (on Unixes).</p> <p>You must make the binary executable by running <code translate="no" dir="ltr">chmod +x /path/to/bazel</code>.</p></li> </ul></li> </ul> <h3 id="build-bazel-git" data-text="Step 2: Download Bazel's sources from GitHub" tabindex="-1">Step 2: Download Bazel's sources from GitHub</h3> <p>If you are familiar with Git, then just git clone https://github.com/bazelbuild/bazel</p> <p>Otherwise:</p> <ol> <li><p>Download the <a href="https://github.com/bazelbuild/bazel/archive/master.zip" class="external">latest sources as a zip file</a>.</p></li> <li><p>Extract the contents somewhere.</p> <p>For example create a <code translate="no" dir="ltr">bazel-src</code> directory under your home directory and extract there.</p></li> </ol> <h3 id="build-bazel-prerequisites" data-text="Step 3: Install prerequisites" tabindex="-1">Step 3: Install prerequisites</h3> <p>Install the same prerequisites as for bootstrapping (see below) -- JDK, C++ compiler, MSYS2 (if you are building on Windows), etc.</p> <h3 id="build-bazel-on-unixes" data-text="Step 4a: Build Bazel on Ubuntu Linux, macOS, and other Unix-like systems" tabindex="-1">Step 4a: Build Bazel on Ubuntu Linux, macOS, and other Unix-like systems</h3> <p>For instructions for Windows, see <a href="#build-bazel-on-windows">Build Bazel on Windows</a>.</p> <p><strong>Goal</strong>: Run Bazel to build a custom Bazel binary (<code translate="no" dir="ltr">bazel-bin/src/bazel-dev</code>).</p> <p><strong>Instructions</strong>:</p> <ol> <li><p>Start a Bash terminal</p></li> <li><p><code translate="no" dir="ltr">cd</code> into the directory where you extracted (or cloned) Bazel's sources.</p> <p>For example if you extracted the sources under your home directory, run:</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">cd ~/bazel-src </code></pre></li> <li><p>Build Bazel from source:</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">bazel build //src:bazel-dev </code></pre> <p>Alternatively you can run <code translate="no" dir="ltr">bazel build //src:bazel --compilation_mode=opt</code> to yield a smaller binary but it's slower to build.</p></li> <li><p>The output will be at <code translate="no" dir="ltr">bazel-bin/src/bazel-dev</code> (or <code translate="no" dir="ltr">bazel-bin/src/bazel</code>).</p></li> </ol> <h3 id="build-bazel-on-windows" data-text="Step 4b: Build Bazel on Windows" tabindex="-1">Step 4b: Build Bazel on Windows</h3> <p>For instructions for Unix-like systems, see <a href="#build-bazel-on-unixes">Ubuntu Linux, macOS, and other Unix-like systems</a>.</p> <p><strong>Goal</strong>: Run Bazel to build a custom Bazel binary (<code translate="no" dir="ltr">bazel-bin\src\bazel-dev.exe</code>).</p> <p><strong>Instructions</strong>:</p> <ol> <li><p>Start Command Prompt (Start Menu > Run > "cmd.exe")</p></li> <li><p><code translate="no" dir="ltr">cd</code> into the directory where you extracted (or cloned) Bazel's sources.</p> <p>For example if you extracted the sources under your home directory, run:</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">cd %USERPROFILE%\bazel-src </code></pre></li> <li><p>Build Bazel from source:</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">bazel build //src:bazel-dev.exe </code></pre> <p>Alternatively you can run <code translate="no" dir="ltr">bazel build //src:bazel.exe --compilation_mode=opt</code> to yield a smaller binary but it's slower to build.</p></li> <li><p>The output will be at <code translate="no" dir="ltr">bazel-bin\src\bazel-dev.exe</code> (or <code translate="no" dir="ltr">bazel-bin\src\bazel.exe</code>).</p></li> </ol> <h3 id="build-bazel-install" data-text="Step 5: Install the built binary" tabindex="-1">Step 5: Install the built binary</h3> <p>Actually, there's nothing to install.</p> <p>The output of the previous step is a self-contained Bazel binary. You can copy it to any directory and use immediately. (It's useful if that directory is on your PATH so that you can run "bazel" everywhere.)</p> <hr> <h2 id="bootstrap-bazel" data-text="Build Bazel from scratch (bootstrapping)" tabindex="-1">Build Bazel from scratch (bootstrapping)</h2> <p>You can also build Bazel from scratch, without using an existing Bazel binary.</p> <h3 id="download-distfile" data-text="Step 1: Download Bazel's sources (distribution archive)" tabindex="-1">Step 1: Download Bazel's sources (distribution archive)</h3> <p>(This step is the same for all platforms.)</p> <ol> <li><p>Download <code translate="no" dir="ltr">bazel-<version>-dist.zip</code> from <a href="https://github.com/bazelbuild/bazel/releases" class="external">GitHub</a>, for example <code translate="no" dir="ltr">bazel-0.28.1-dist.zip</code>.</p> <p><strong>Attention</strong>:</p> <ul> <li>There is a <strong>single, architecture-independent</strong> distribution archive. There are no architecture-specific or OS-specific distribution archives.</li> <li>These sources are <strong>not the same as the GitHub source tree</strong>. You have to use the distribution archive to bootstrap Bazel. You cannot use a source tree cloned from GitHub. (The distribution archive contains generated source files that are required for bootstrapping and are not part of the normal Git source tree.)</li> </ul></li> <li><p>Unpack the distribution archive somewhere on disk.</p> <p>You should verify the signature made by Bazel's <a href="https://bazel.build/bazel-release.pub.gpg">release key</a> 3D5919B448457EE0.</p></li> </ol> <h3 id="bootstrap-unix-overview" data-text="Step 2a: Bootstrap Bazel on Ubuntu Linux, macOS, and other Unix-like systems" tabindex="-1">Step 2a: Bootstrap Bazel on Ubuntu Linux, macOS, and other Unix-like systems</h3> <p>For instructions for Windows, see <a href="#bootstrap-windows">Bootstrap Bazel on Windows</a>.</p> <h4 id="bootstrap-unix-prereq" data-text="2.1. Install the prerequisites" tabindex="-1">2.1. Install the prerequisites</h4> <ul> <li><p><strong>Bash</strong></p></li> <li><p><strong>zip, unzip</strong></p></li> <li><p><strong>C++ build toolchain</strong></p></li> <li><p><strong>JDK.</strong> Version 11 is required.</p></li> <li><p><strong>Python</strong>. Versions 2 and 3 are supported, installing one of them is enough.</p></li> </ul> <p>For example on Ubuntu Linux you can install these requirements using the following command:</p> <pre class="prettyprint lang-sh" translate="no" dir="ltr"><code translate="no" dir="ltr">sudo apt-get install build-essential openjdk-11-jdk python zip unzip </code></pre> <h4 id="bootstrap-unix" data-text="2.2. Bootstrap Bazel on Unix" tabindex="-1">2.2. Bootstrap Bazel on Unix</h4> <ol> <li><p>Open a shell or Terminal window.</p></li> <li><p><code translate="no" dir="ltr">cd</code> to the directory where you unpacked the distribution archive.</p></li> <li><p>Run the compilation script: <code translate="no" dir="ltr">env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh</code>.</p></li> </ol> <p>The compiled output is placed into <code translate="no" dir="ltr">output/bazel</code>. This is a self-contained Bazel binary, without an embedded JDK. You can copy it anywhere or use it in-place. For convenience, copy this binary to a directory that's on your <code translate="no" dir="ltr">PATH</code> (such as <code translate="no" dir="ltr">/usr/local/bin</code> on Linux).</p> <p>To build the <code translate="no" dir="ltr">bazel</code> binary in a reproducible way, also set <a href="https://reproducible-builds.org/specs/source-date-epoch/"><code translate="no" dir="ltr">SOURCE_DATE_EPOCH</code></a> in the "Run the compilation script" step.</p> <h3 id="bootstrap-windows-overview" data-text="Step 2b: Bootstrap Bazel on Windows" tabindex="-1">Step 2b: Bootstrap Bazel on Windows</h3> <p>For instructions for Unix-like systems, see <a href="#bootstrap-unix">Bootstrap Bazel on Ubuntu Linux, macOS, and other Unix-like systems</a>.</p> <h4 id="bootstrap-windows-prereq" data-text="2.1. Install the prerequisites" tabindex="-1">2.1. Install the prerequisites</h4> <ul> <li><p><a href="https://msys2.github.io/">MSYS2 shell</a></p></li> <li><p><strong>The MSYS2 packages for zip and unzip.</strong> Run the following command in the MSYS2 shell:</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">pacman -S zip unzip patch </code></pre></li> <li><p><strong>The Visual C++ compiler.</strong> Install the Visual C++ compiler either as part of Visual Studio 2015 or newer, or by installing the latest <a href="https://aka.ms/BuildTools">Build Tools for Visual Studio 2017</a>.</p></li> <li><p><strong>JDK.</strong> Version 11 is required.</p></li> <li><p><strong>Python</strong>. Versions 2 and 3 are supported, installing one of them is enough. You need the Windows-native version (downloadable from <a href="https://www.python.org">https://www.python.org</a>). Versions installed via pacman in MSYS2 will not work.</p></li> </ul> <h4 id="bootstrap-windows" data-text="2.2. Bootstrap Bazel on Windows" tabindex="-1">2.2. Bootstrap Bazel on Windows</h4> <ol> <li><p>Open the MSYS2 shell.</p></li> <li><p>Set the following environment variables:</p> <ul> <li>Either <code translate="no" dir="ltr">BAZEL_VS</code> or <code translate="no" dir="ltr">BAZEL_VC</code> (they are <em>not</em> the same): Set to the path to the Visual Studio directory (BAZEL_V<b>S</b>) or to the Visual C++ directory (BAZEL_V<b>C</b>). Setting one of them is enough.</li> <li><p><code translate="no" dir="ltr">BAZEL_SH</code>: Path of the MSYS2 <code translate="no" dir="ltr">bash.exe</code>. See the command in the examples below.</p> <p>Do not set this to <code translate="no" dir="ltr">C:\Windows\System32\bash.exe</code>. (You have that file if you installed Windows Subsystem for Linux.) Bazel does not support this version of <code translate="no" dir="ltr">bash.exe</code>.</p></li> <li><p><code translate="no" dir="ltr">PATH</code>: Add the Python directory.</p></li> <li><p><code translate="no" dir="ltr">JAVA_HOME</code>: Set to the JDK directory.</p></li> </ul> <p><strong>Example</strong> (using BAZEL_V<b>S</b>):</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">export BAZEL_VS="C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools" export BAZEL_SH="$(cygpath -m $(realpath $(which bash)))" export PATH="/c/python27:$PATH" export JAVA_HOME="C:/Program Files/Java/jdk1.8.0_112" </code></pre> <p>or (using BAZEL_V<b>C</b>):</p> <pre class="prettyprint" translate="no" dir="ltr"><code translate="no" dir="ltr">export BAZEL_VC="C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC" export BAZEL_SH="$(cygpath -m $(realpath $(which bash)))" export PATH="/c/python27:$PATH" export JAVA_HOME="C:/Program Files/Java/jdk1.8.0_112" </code></pre></li> <li><p><code translate="no" dir="ltr">cd</code> to the directory where you unpacked the distribution archive.</p></li> <li><p>Run the compilation script: <code translate="no" dir="ltr">env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" ./compile.sh</code></p></li> </ol> <p>The compiled output is placed into <code translate="no" dir="ltr">output/bazel.exe</code>. This is a self-contained Bazel binary, without an embedded JDK. You can copy it anywhere or use it in-place. For convenience, copy this binary to a directory that's on your <code translate="no" dir="ltr">PATH</code>.</p> <p>To build the <code translate="no" dir="ltr">bazel.exe</code> binary in a reproducible way, also set <a href="https://reproducible-builds.org/specs/source-date-epoch/"><code translate="no" dir="ltr">SOURCE_DATE_EPOCH</code></a> in the "Run the compilation script" step.</p> <p>You don't need to run Bazel from the MSYS2 shell. You can run Bazel from the Command Prompt (<code translate="no" dir="ltr">cmd.exe</code>) or PowerShell.</p> </div> <devsite-thumb-rating position="footer"> </devsite-thumb-rating> <devsite-feedback position="footer" project-name="Bazel" product-id="5052038" bucket="https-bazel-build" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="footer" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png" > <button> Send feedback </button> </devsite-feedback> <div class="devsite-floating-action-buttons"> </div> </article> <devsite-content-footer class="nocontent"> <p>Except as otherwise noted, the content of this page is licensed under the <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 License</a>, and code samples are licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a>. For details, see the <a href="https://developers.google.com/site-policies">Google Developers Site Policies</a>. Java is a registered trademark of Oracle and/or its affiliates.</p> <p>Last updated 2024-10-22 UTC.</p> </devsite-content-footer> <devsite-notification > </devsite-notification> <div class="devsite-content-data"> <template class="devsite-thumb-rating-feedback"> <devsite-feedback position="thumb-rating" project-name="Bazel" product-id="5052038" bucket="https-bazel-build" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="thumb-rating" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/touchicon-180.png" > <button> Need to tell us more? </button> </devsite-feedback> </template> <template class="devsite-content-data-template"> [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-22 UTC."],[],[]] </template> </div> </devsite-content> </main> <devsite-footer-promos class="devsite-footer"> </devsite-footer-promos> <devsite-footer-linkboxes class="devsite-footer"> <nav class="devsite-footer-linkboxes nocontent" aria-label="Footer links"> <ul class="devsite-footer-linkboxes-list"> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">About</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/community/users" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Who's using Bazel </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/contribute/" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Contribute </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/contribute/contribution-policy" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Governance model </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/release" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Release model </a> </li> <li class="devsite-footer-linkbox-item"> <a href="/brand" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 5)" > Brand guidelines </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Stay connected</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="//blog.bazel.build" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Blog </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//github.com/bazelbuild/bazel" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > GitHub </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//twitter.com/bazelbuild" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Twitter </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//youtube.com/user/googleOSPO" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > YouTube </a> </li> </ul> </li> <li class="devsite-footer-linkbox "> <h3 class="devsite-footer-linkbox-heading no-link">Support</h3> <ul class="devsite-footer-linkbox-list"> <li class="devsite-footer-linkbox-item"> <a href="/help" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 1)" > Support </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//github.com/bazelbuild/bazel/issues" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 2)" > Issue tracker </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//slack.bazel.build" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 3)" > Slack </a> </li> <li class="devsite-footer-linkbox-item"> <a href="//stackoverflow.com/questions/tagged/bazel" class="devsite-footer-linkbox-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Footer Link (index 4)" > Stack Overflow </a> </li> </ul> </li> </ul> </nav> </devsite-footer-linkboxes> <devsite-footer-utility class="devsite-footer"> <div class="devsite-footer-utility nocontent"> <nav class="devsite-footer-utility-links" aria-label="Utility links"> <ul class="devsite-footer-utility-list"> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/terms" data-category="Site-Wide Custom Events" data-label="Footer Terms link" > Terms </a> </li> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/privacy" data-category="Site-Wide Custom Events" data-label="Footer Privacy link" > Privacy </a> </li> <li class="devsite-footer-utility-item glue-cookie-notification-bar-control"> <a class="devsite-footer-utility-link gc-analytics-event" href="#" data-category="Site-Wide Custom Events" data-label="Footer Manage cookies link" aria-hidden="true" > Manage cookies </a> </li> </ul> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> </nav> </div> </devsite-footer-utility> <devsite-panel></devsite-panel> </section></section> <devsite-sitemask></devsite-sitemask> <devsite-snackbar></devsite-snackbar> <devsite-tooltip ></devsite-tooltip> <devsite-heading-link></devsite-heading-link> <devsite-analytics> <script type="application/json" analytics>[{"dimensions": {"dimension4": "en", "dimension2": false, "dimension3": "en", "dimension1": "Signed out", "dimension5": false}, "gaid": "UA-61082125-3", "metrics": {}, "purpose": 0}]</script> <script type="application/json" tag-management>{"at": "True", "ga4": [{"id": "G-GBZW986TQ3", "purpose": 0}], "ga4p": [{"id": "G-GBZW986TQ3", "purpose": 0}], "gtm": [], "parameters": {"internalUser": "False", "language": {"machineTranslated": "False", "requested": "en", "served": "en"}, "pageType": "article", "projectName": "Bazel", "signedIn": "False", "tenant": "bazel", "recommendations": {"sourcePage": "", "sourceType": 0, "sourceRank": 0, "sourceIdenticalDescriptions": 0, "sourceTitleWords": 0, "sourceDescriptionWords": 0, "experiment": ""}, "experiment": {"ids": ""}}}</script> </devsite-analytics> <devsite-badger></devsite-badger> <script nonce="3K/ofYMGK4XkIHgKTb3UOpRBsg0uIs"> (function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i; t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0]; E.parentNode.insertBefore(t,E);})(window, document, 'script', 'https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/js/app_loader.js', '[40,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel","https://bazel-dot-devsite-v2-prod-3p.appspot.com",null,null,["/_pwa/bazel/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/favicon-prod.png","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/bazel/images/lockup.svg","https://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyCNm9YxQumEXwGJgTDjxoxXK6m1F-9720Q","AIzaSyCc76DZePGtoyUjqKrLdsMGk_ry7sljLbY","bazel.build","AIzaSyB9bqgQ2t11WJsOX8qNsCQ6U-w91mmqF-I","AIzaSyAdYnStPdzjcJJtQ0mvIaeaMKj7_t6J_Fg",null,null,null,["EngEduTelemetry__enable_engedu_telemetry","Profiles__enable_page_saving","Experiments__reqs_query_experiments","Profiles__enable_recognition_badges","SignIn__enable_auto_login_multi_account","Profiles__enable_profile_collections","Profiles__require_profile_eligibility_for_signin","Cloud__enable_legacy_calculator_redirect","MiscFeatureFlags__enable_view_transitions","Concierge__enable_pushui","Profiles__enable_release_notes_notifications","MiscFeatureFlags__developers_footer_dark_image","Cloud__enable_cloudx_ping","Search__enable_dynamic_content_confidential_banner","CloudShell__cloud_shell_button","Profiles__enable_public_developer_profiles","DevPro__enable_developer_subscriptions","TpcFeatures__enable_required_headers","MiscFeatureFlags__enable_project_variables","Profiles__enable_developer_profiles_callout","Cloud__enable_cloud_facet_chat","Search__enable_page_map","Search__enable_suggestions_from_borg","Cloud__enable_cloud_shell","Cloud__enable_cloud_dlp_service","MiscFeatureFlags__enable_firebase_utm","OnSwitch__enable","Profiles__enable_complete_playlist_endpoint","SignIn__enable_oauth_multi_account_support","TpcFeatures__enable_mirror_tenant_redirects","Analytics__enable_clearcut_logging","Search__enable_ai_eligibility_checks","Cloud__enable_cloud_shell_fte_user_flow","MiscFeatureFlags__enable_variable_operator","Profiles__enable_dashboard_curated_recommendations","CloudShell__cloud_code_overflow_menu","DevPro__enable_cloud_innovators_plus","Cloud__enable_llm_concierge_chat","Profiles__enable_awarding_url","MiscFeatureFlags__emergency_css","Profiles__enable_completecodelab_endpoint","MiscFeatureFlags__developers_footer_image","SignIn__enable_refresh_access_tokens","MiscFeatureFlags__enable_explain_this_code","Cloud__enable_cloudx_experiment_ids","Cloud__enable_free_trial_server_call","BookNav__enable_tenant_cache_key"],null,null,"AIzaSyA58TaKli1DculwmAmbpzLVGuWc8eCQgQc","https://developerscontentserving-pa.googleapis.com","AIzaSyDWBU60w0P9hEkr29kkksYs8Z7gvZ8u_wc","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[40,"bazel","Bazel","bazel.build",null,"bazel-dot-devsite-v2-prod-3p.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],null,null,null,null,[1,1,1],[1,1,null,1,1]],null,[56,null,null,null,null,null,"/images/lockup.svg",null,null,null,null,1,null,null,null,null,null,null,null,null,null,1,null,null,null,null,[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[6,7,1,18,20,22,23,29,37,39,40,43],null,[[],[1,1]],[[["UA-61082125-3"],["UA-61082125-4"],null,null,["UA-61082125-5"],null,null,[["G-GBZW986TQ3"],null,null,[["G-GBZW986TQ3",1]]],[["UA-61082125-3",1]],null,[["UA-61082125-5",1]],null,1],[[2,2],[5,8],[3,4],[1,1],[4,5]]],null,4]]') </script> <devsite-a11y-announce></devsite-a11y-announce> </body> </html>