# 使用 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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-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
- **版本:** 2.6.4
- **来源摘要:** Fast Lexical Analyzer, generates Scanners (tokenizers)
- **主页:** <https://github.com/westes/flex>
- **仓库:** <https://github.com/westes/flex>
- **最后更新:** 2026-06-22T14:03:20-07:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

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

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 2.6.4
## 项目历史与用法

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

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

- 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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | Static libraries for the flex scanner generator | https://github.com/westes/flex


## 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
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
