# 使用 Homebrew, apk, apt, dnf, MacPorts, Nix, pacman, zypper 安装 flex

查看 flex 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

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

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install flex
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install flex
```

  证据: 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
```

  证据: 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
```

  证据: 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
```

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

- Nix (92%):

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

  证据: 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
```

  证据: 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
```

  证据: openSUSE Tumbleweed package metadata: flex from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

## 软件包事实

- **软件包键:** brew:flex
- **软件包管理器:** Homebrew
- **软件包管理器页面:** <https://formulae.brew.sh/formula/flex>
- **版本:** 2.6.4
- **来源摘要:** Fast Lexical Analyzer, generates Scanners (tokenizers)
- **主页:** <https://github.com/westes/flex>
- **仓库:** <https://github.com/westes/flex>
- **许可证:** BSD-2-Clause
- **源码归档:** <https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz>
- **最后更新:** 2026-06-22T14:03:20-07:00
- **已生成:** 2026-08-04T22:13:35+00:00

## 可执行文件

- flex (cli)
- flex++ (cli)
- lex (cli)
- flex (别名)
- flex++ (别名)
- lex (别名)

## 依赖

- gettext

## 构建依赖

- help2man

## macOS 提供的库

- m4

## 安装行为

- post-install 钩子: 未定义
- Bottle: 可用 于 arm64_big_sur, arm64_linux, arm64_monterey, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, big_sur, catalina, monterey, sonoma, ventura

## 版本和新鲜度

- 页面生成时间: 2026-08-04
- 管理器版本: 2.6.4
- 管理器更新时间: 2026-06-22
- 本地数据: OK
- 上游仓库: https://github.com/westes/flex
- 信息: No cached GitHub release or tag data was available.
## 项目历史与用法

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.

### 项目历史

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.

### 采用历史

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.

### 使用方式

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.

### 为什么软件包爱好者会关心

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.

### 时间线

- 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.

### 来源

- <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>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 源数据库详情

- **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

## 其他软件包管理器记录

- 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-25.fc45: normalized package name match | Fedora Rawhide package metadata: flex from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/210a2053c8e007daf9ae39c2a21daaed9b2ddd07d63ecffa597050361e73650c-primary.xml.zst | A tool for generating scanners (text pattern recognizers) | https://github.com/westes/flex
- dnf - libfl-devel - 2.6.4-25.fc45: 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/210a2053c8e007daf9ae39c2a21daaed9b2ddd07d63ecffa597050361e73650c-primary.xml.zst | Development files for the flex scanner generator | https://github.com/westes/flex
- dnf - libfl-static - 2.6.4-25.fc45: 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/210a2053c8e007daf9ae39c2a21daaed9b2ddd07d63ecffa597050361e73650c-primary.xml.zst | Static libraries for the flex scanner generator | https://github.com/westes/flex


## 相关链接

- [Source-control packages](https://pkg.so/zh-hans/source-control-tools/) - Belongs to a source-control command family.
- [Terminal utility packages](https://pkg.so/zh-hans/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://pkg.so/zh-hans/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://pkg.so/zh-hans/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [gettext](https://pkg.so/zh-hans/brew/gettext/) - Runtime dependency declared by Homebrew.
- [help2man](https://pkg.so/zh-hans/brew/help2man/) - Build dependency declared by Homebrew.
- [crosstool-ng](https://pkg.so/zh-hans/brew/crosstool-ng/) - Popular package that depends on this formula.
- [mdk](https://pkg.so/zh-hans/brew/mdk/) - Popular package that depends on this formula.
- [dwarf](https://pkg.so/zh-hans/brew/dwarf/) - Popular package that depends on this formula.
- [quex](https://pkg.so/zh-hans/brew/quex/) - Shares pkgdb curated category or tags: c, cli, developer-tools, lexer-generator.
- [glib](https://pkg.so/zh-hans/brew/glib/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [libdeflate](https://pkg.so/zh-hans/brew/libdeflate/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [hello](https://pkg.so/zh-hans/brew/hello/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [libdatrie](https://pkg.so/zh-hans/brew/libdatrie/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [ccache](https://pkg.so/zh-hans/brew/ccache/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [nspr](https://pkg.so/zh-hans/brew/nspr/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [cffi](https://pkg.so/zh-hans/brew/cffi/) - Shares pkgdb curated category or tags: c, cli, developer-tools.
- [peg-markdown](https://pkg.so/zh-hans/brew/peg-markdown/) - Local package facts share a topical domain. Shared terms: c, cli, developer, developer-tools, gettext.
- [cutter-cli](https://pkg.so/zh-hans/brew/cutter-cli/) - Local package facts share a topical domain. Shared terms: c, cli, developer, developer-tools, gettext.
- [lunar-date](https://pkg.so/zh-hans/brew/lunar-date/) - 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/mxcl/pkgdb/blob/main/combined/flex.yml)


## 来源

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