# Install flex with Homebrew, apk, apt, dnf, MacPorts, Nix, pacman, zypper

Fast Lexical Analyzer, generates Scanners (tokenizers). Version 2.6.4 via Homebrew; verified 2026-06-22.

## Install

```sh
sudo av install brew:flex
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install flex
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install flex
```

  Evidence: MacPorts ports tree: devel/flex/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add flex
```

  Evidence: Alpine Linux edge package indexes: flex from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install flex
```

  Evidence: Debian stable package indexes: flex from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- dnf (92%):

```sh
sudo dnf install flex
```

  Evidence: Fedora Rawhide package metadata: flex from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst

- Nix (92%):

```sh
nix profile install nixpkgs#flex
```

  Evidence: nixpkgs package indexes: flex from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

- pacman (92%):

```sh
sudo pacman -S flex
```

  Evidence: Arch Linux sync databases: flex from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz

- zypper (92%):

```sh
sudo zypper install flex
```

  Evidence: openSUSE Tumbleweed package metadata: flex from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst

## Package facts

- **Package key:** brew:flex
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/flex>
- **Version:** 2.6.4
- **Source summary:** Fast Lexical Analyzer, generates Scanners (tokenizers)
- **Homepage:** <https://github.com/westes/flex>
- **Repository:** <https://github.com/westes/flex>
- **Upstream docs:** <https://westes.github.io/flex/manual>
- **License:** BSD-2-Clause
- **Source archive:** <https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz>
- **Last updated:** 2026-06-22T14:03:20-07:00
- **Generated:** 2026-07-08T07:18:31+00:00

## Executables

- flex (cli)
- flex++ (cli)
- lex (cli)
- flex (alias)
- flex++ (alias)
- lex (alias)

## Dependencies

- gettext

## Build dependencies

- help2man

## Uses from macOS

- m4

## Install behavior

- Post-install hook: not defined
- Bottle: available on arm64_big_sur, arm64_linux, arm64_monterey, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, big_sur, catalina, monterey, sonoma, ventura

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 2.6.4
- Package-manager updated: 2026-06-22
- Local data: ok
- Upstream repository: https://github.com/westes/flex
- info: No cached GitHub release or tag data was available.
## Project history and usage

flex is the fast lexical analyzer generator, the long-running free-software successor in the lex family. It generates scanners for recognizing lexical patterns in text and remains a foundational build-time package for C, C++, parser, compiler, and language-tooling stacks.

### Project history

The upstream README describes flex as a tool for generating scanners and notes that the code derives from software contributed to Berkeley by Vern Paxson. Its distribution includes user documentation, examples, tests, internationalization files, and libfl support.

The project moved its main codebase, issue tracking, pull requests, and source releases to GitHub during the 2.6.1 release cycle in 2016, after earlier SourceForge-era mailing-list infrastructure. The 2.6.x NEWS entries record modernization work around generated scanners, portability, cross compilation, tests, build tooling, and release artifacts.

### Adoption history

flex is a standard dependency in Unix-like development environments because many source packages generate or ship scanners built from `.l` files. The supplied package metadata records availability across apk, Homebrew, Debian, Fedora, MacPorts, Nix, pacman, Ubuntu, and zypper, reflecting its role as a baseline developer tool rather than a niche application.

### How it is used

Users write lexical rules and run flex to generate C or C++ scanner code. The generated scanner is then compiled into a program, commonly alongside parser generators and build systems for compilers, interpreters, protocol tools, data importers, and other text-processing software.

Package maintainers care about whether a release tarball includes generated intermediate files, which flex version built the distributed scanner, and whether cross-compilation and bootstrap paths work. The official NEWS repeatedly calls out these build and portability concerns.

### Why package nerds care

flex is one of the canonical examples of a package that is both a user-facing command and a build dependency. It shows up in dependency graphs far from compiler projects because scanner generation is a common prebuild step, and its own bootstrap story matters to source-based distributions.

### Timeline

- 1980s: flex originates from Berkeley-contributed scanner-generator work by Vern Paxson.
- 2013: westes/flex GitHub repository created.
- 2016: 2.6.1 announces GitHub as the project host for code, releases, issues, and pull requests.
- 2016: 2.6.3 improves cross-compilation and bootstrap behavior.
- 2017: 2.6.4 stable release includes portability, build, scanner, documentation, and test-suite fixes.

### Related projects

- lex is the historical Unix scanner generator lineage to which flex is related.
- Bison, yacc-family parser generators, autotools, m4, and libfl are common adjacent tools in flex build and usage contexts.
- SourceForge remains relevant for flex mailing-list archives even though the codebase and releases are on GitHub.

### Sources

- <https://api.github.com/repos/westes/flex>
- <https://api.github.com/repos/westes/flex/tags?per_page=100>
- <https://formulae.brew.sh/formula/flex>
- <https://github.com/westes/flex>
- <https://raw.githubusercontent.com/westes/flex/master/NEWS>
- <https://raw.githubusercontent.com/westes/flex/master/README.md>
- <https://westes.github.io/flex/manual>


## Security Notes

narrow executable package without higher-risk signals.

- **Geiger risk:** green / low
- narrow executable package without higher-risk signals

## Source Database Details

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** flex
- **Version Scheme:** 0
- **Revision:** 2
- **Head Version:** HEAD
- **Requirements:** macos
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** yes
- **URL Keys:** head, stable

## Other Package-Manager Records

- Debian apt - flex - 2.6.4-8.2+b4: normalized package name match | Debian stable package indexes: flex from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | fast lexical analyzer generator | https://github.com/westes/flex
- Debian apt - flex-doc - 2.6.4-8.2: normalized package name match | Debian stable package indexes: flex-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Documentation for flex (a fast lexical analyzer generator) | https://github.com/westes/flex
- Debian apt - libfl-dev - 2.6.4-8.2+b4: normalized package name match | Debian stable package indexes: libfl-dev from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | static library for flex (a fast lexical analyzer generator) | https://github.com/westes/flex
- Debian apt - libfl2 - 2.6.4-8.2+b4: normalized package name match | Debian stable package indexes: libfl2 from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | SHARED library for flex (a fast lexical analyzer generator) | https://github.com/westes/flex
- Nix - flex: normalized package name match | nixpkgs package indexes: flex from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix
- Ubuntu apt - flex - 2.6.4-8.2build1: normalized package name match | Ubuntu 24.04 LTS package indexes: flex from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | fast lexical analyzer generator | https://github.com/westes/flex
- Ubuntu apt - flex-doc - 2.6.4-8.2build1: normalized package name match | Ubuntu 24.04 LTS package indexes: flex-doc from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | Documentation for flex (a fast lexical analyzer generator) | https://github.com/westes/flex
- Ubuntu apt - libfl-dev - 2.6.4-8.2build1: normalized package name match | Ubuntu 24.04 LTS package indexes: libfl-dev from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | static library for flex (a fast lexical analyzer generator) | https://github.com/westes/flex
- Ubuntu apt - libfl2 - 2.6.4-8.2build1: normalized package name match | Ubuntu 24.04 LTS package indexes: libfl2 from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | SHARED library for flex (a fast lexical analyzer generator) | https://github.com/westes/flex
- apk - flex - 2.6.4-r8: normalized package name match | Alpine Linux edge package indexes: flex from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | A tool for generating text-scanning programs | https://github.com/westes/flex
- apk - flex-dev - 2.6.4-r8: normalized package name match | Alpine Linux edge package indexes: flex-dev from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | A tool for generating text-scanning programs (development files) | https://github.com/westes/flex
- apk - flex-doc - 2.6.4-r8: normalized package name match | Alpine Linux edge package indexes: flex-doc from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | A tool for generating text-scanning programs (documentation) | https://github.com/westes/flex
- apk - flex-libs - 2.6.4-r8: normalized package name match | Alpine Linux edge package indexes: flex-libs from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | A tool for generating text-scanning programs (libraries) | https://github.com/westes/flex
- dnf - flex - 2.6.4-24.fc44: normalized package name match | Fedora Rawhide package metadata: flex from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | A tool for generating scanners (text pattern recognizers) | https://github.com/westes/flex
- dnf - libfl-devel - 2.6.4-24.fc44: normalized package name match | Fedora Rawhide package metadata: libfl-devel from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | Development files for the flex scanner generator | https://github.com/westes/flex
- dnf - libfl-static - 2.6.4-24.fc44: normalized package name match | Fedora Rawhide package metadata: libfl-static from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | Static libraries for the flex scanner generator | https://github.com/westes/flex


## Related links

- [Source-control packages](https://www.automicvault.com/pkg/source-control-tools/) - Belongs to a source-control command family.
- [Terminal utility packages](https://www.automicvault.com/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://www.automicvault.com/pkg/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://www.automicvault.com/pkg/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [gettext](https://www.automicvault.com/pkg/brew/gettext/) - Runtime dependency declared by Homebrew.
- [help2man](https://www.automicvault.com/pkg/brew/help2man/) - Build dependency declared by Homebrew.
- [crosstool-ng](https://www.automicvault.com/pkg/brew/crosstool-ng/) - Popular package that depends on this formula.
- [dwarf](https://www.automicvault.com/pkg/brew/dwarf/) - Popular package that depends on this formula.
- [mdk](https://www.automicvault.com/pkg/brew/mdk/) - Popular package that depends on this formula.
- [re2c](https://www.automicvault.com/pkg/brew/re2c/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools, lexer-generator.
- [quex](https://www.automicvault.com/pkg/brew/quex/) - Shares av.db curated category or tags: c, cli, developer-tools, lexer-generator.
- [jflex](https://www.automicvault.com/pkg/brew/jflex/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools, lexer-generator.
- [jasmin](https://www.automicvault.com/pkg/brew/jasmin/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools.
- [lit](https://www.automicvault.com/pkg/brew/lit/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools.
- [treecc](https://www.automicvault.com/pkg/brew/treecc/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools.
- [aarch64-elf-gcc](https://www.automicvault.com/pkg/brew/aarch64-elf-gcc/) - Shares av.db curated category or tags: c, cli, developer-tools.
- [abi-dumper](https://www.automicvault.com/pkg/brew/abi-dumper/) - Shares av.db curated category or tags: c, cli, developer-tools.
- [peg-markdown](https://www.automicvault.com/pkg/brew/peg-markdown/) - Local package facts share a topical domain. Shared terms: c, cli, developer, developer-tools, gettext.

## Combined YAML source

View the package source record on GitHub. [combined/flex.yml](https://github.com/automic-vault/db/blob/main/combined/flex.yml)


## Sources

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
