https://github.com/Homebrew/ruby-macho
🔩 A pure-Ruby library for parsing Mach-O files.
https://github.com/Homebrew/ruby-macho
Keywords
apple homebrew mach macos ruby ruby-gem ruby-library
Keywords from Contributors
rubygems feature-flag sorbet feature-toggle feature oauth2-server oauth2-provider oauth2 oauth identity
Last synced: about 15 hours ago
JSON representation
Repository metadata
🔩 A pure-Ruby library for parsing Mach-O files.
- Host: GitHub
- URL: https://github.com/Homebrew/ruby-macho
- Owner: Homebrew
- License: mit
- Created: 2015-07-15T21:40:05.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2026-08-14T10:54:35.000Z (3 days ago)
- Last Synced: 2026-08-16T10:09:25.976Z (1 day ago)
- Topics: apple, homebrew, mach, macos, ruby, ruby-gem, ruby-library
- Language: Ruby
- Homepage: https://rubygems.org/gems/ruby-macho
- Size: 2.29 MB
- Stars: 258
- Watchers: 13
- Forks: 35
- Open Issues: 0
- Releases: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
ruby-macho
A Ruby library for examining and modifying Mach-O files.
What is a Mach-O file?
The Mach-O file format is used by macOS
and iOS (among others) as a general purpose binary format for object files,
executables, dynamic libraries, and so forth.
Installation
ruby-macho can be installed via RubyGems:
$ gem install ruby-macho
Documentation
Full documentation is available on RubyDoc.
A quick example of what ruby-macho can do:
require 'macho'
file = MachO::MachOFile.new("/path/to/my/binary")
# get the file's type (object, dynamic lib, executable, etc)
file.filetype # => :execute
# get all load commands in the file and print their offsets:
file.load_commands.each do |lc|
puts "#{lc.type}: offset #{lc.offset}, size: #{lc.cmdsize}"
end
# access a specific load command
lc_vers = file[:LC_VERSION_MIN_MACOSX].first
puts lc_vers.version_string # => "10.10.0"
Ad-hoc code signing
Changing a Mach-O load command invalidates any existing code signature. This is
especially important when Homebrew pours bottles on Apple Silicon, where native
code must remain signed after its paths are rewritten. MachO.codesign! creates
the required ad-hoc signature in Ruby instead of invoking /usr/bin/codesign:
MachO.codesign!("/path/to/my/binary")
What works?
- Reading data from x86/x86_64/arm64/PPC Mach-O files (other architectures are unsupported, but may work)
- Changing the IDs of Mach-O and Fat dylibs
- Changing install names in Mach-O and Fat files
- Adding, deleting, and modifying rpaths.
- Parsing embedded code signatures and applying ad-hoc signatures in pure Ruby.
What needs to be done?
- Unit and performance testing.
Contributing, setting up overcommit and the linters
In order to keep the repo, docs and data tidy, we use a tool called overcommit
to connect up the git hooks to a set of quality checks. The fastest way to get setup is to run the following to make
sure you have all the tools:
gem install overcommit bundler
bundle install
overcommit --install
Attribution
- Constants were taken from Apple, Inc's
loader.hincctools/include/mach-o.
(Apple Public Source License 2.0). - Code-signing constants and structures follow Apple, Inc's
cs_blobs.hin XNU. - Binary files used for testing were taken from The LLVM Project. (Apache License v2.0 with LLVM Exceptions).
License
ruby-macho is licensed under the MIT License.
For the exact terms, see the license file.
Owner metadata
- Name: Homebrew
- Login: Homebrew
- Email:
- Kind: organization
- Description: The missing package manager for macOS (or Linux)
- Website: https://brew.sh
- Location: GitHub
- Twitter: MacHomebrew
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1503512?v=4
- Repositories: 28
- Last ynced at: 2024-10-29T17:10:41.779Z
- Profile URL: https://github.com/Homebrew
GitHub Events
Total
- Delete event: 203
- Member event: 1
- Pull request event: 401
- Fork event: 4
- Watch event: 10
- Issue comment event: 20
- Push event: 240
- Pull request review comment event: 9
- Pull request review event: 115
- Create event: 213
Last Year
- Delete event: 37
- Member event: 1
- Pull request event: 81
- Watch event: 1
- Issue comment event: 6
- Push event: 59
- Pull request review comment event: 9
- Pull request review event: 24
- Create event: 46
Committers metadata
Last synced: 1 day ago
Total Commits: 1,226
Total Committers: 21
Avg Commits per committer: 58.381
Development Distribution Score (DDS): 0.6
Commits in past year: 141
Committers in past year: 7
Avg Commits per committer in past year: 20.143
Development Distribution Score (DDS) in past year: 0.44
| Name | Commits | |
|---|---|---|
| dependabot[bot] | 4****] | 491 |
| William Woodruff | w****m@t****m | 343 |
| dependabot-preview[bot] | 2****] | 159 |
| BrewTestBot | 1****t | 97 |
| dependabot[bot] | s****t@d****m | 43 |
| Martin Afanasjew | m****n@a****e | 22 |
| Mike McQuaid | m****e@m****m | 17 |
| Patrick Linnane | p****k@l****o | 12 |
| Bo Anderson | m****l@b****e | 11 |
| Carlo Cabrera | 3****b | 7 |
| BrewTestBot | h****t@l****g | 5 |
| Rick Mark | r****k@o****m | 5 |
| Kevin | a****k@g****m | 4 |
| Misty De Meo | m****o@g****m | 3 |
| Andrew Nesbitt | a****z@g****m | 1 |
| Branch Vincent | b****t@g****m | 1 |
| Jonathan Chang | j****1@g****m | 1 |
| Rylan Polster | r****r@g****m | 1 |
| Thierry Moisan | t****n@g****m | 1 |
| Juhani Krekelä | j****i@k****i | 1 |
| leonklingele | g****t@l****e | 1 |
Committer domains:
- leonklingele.de: 1
- krekelä.fi: 1
- lists.sfconservancy.org: 1
- boanderson.me: 1
- linnane.io: 1
- mikemcquaid.com: 1
- afanasjew.de: 1
- dependabot.com: 1
- tuffbizz.com: 1
Issue and Pull Request metadata
Last synced: 3 days ago
Total issues: 17
Total pull requests: 779
Average time to close issues: almost 4 years
Average time to close pull requests: about 15 hours
Total issue authors: 5
Total pull request authors: 11
Average comments per issue: 2.65
Average comments per pull request: 0.18
Merged pull request: 688
Bot issues: 4
Bot pull requests: 602
Past year issues: 1
Past year pull requests: 76
Past year average time to close issues: about 3 hours
Past year average time to close pull requests: about 5 hours
Past year issue authors: 1
Past year pull request authors: 7
Past year average comments per issue: 1.0
Past year average comments per pull request: 0.17
Past year merged pull request: 74
Past year bot issues: 0
Past year bot pull requests: 45
Top Issue Authors
- woodruffw (9)
- dependabot[bot] (4)
- rickmark (2)
- nortti0 (1)
- abarisain (1)
Top Pull Request Authors
- dependabot[bot] (602)
- BrewTestBot (113)
- woodruffw (20)
- Bo98 (13)
- p-linnane (11)
- MikeMcQuaid (6)
- apainintheneck (4)
- Moisan (4)
- carlocab (3)
- andrew (2)
- nortti0 (1)
Top Issue Labels
- help wanted (10)
- enhancement (7)
- dependencies (4)
- test-suite (3)
- ruby (3)
- outdated (2)
- bug (2)
- github_actions (2)
- long-term (2)
- optimization (1)
Top Pull Request Labels
- dependencies (600)
- ruby (413)
- github_actions (206)
- outdated (177)
- enhancement (5)
- in progress (1)
- test-suite (1)
- performance (1)
- Stale (1)
Package metadata
- Total packages: 5
-
Total downloads:
- rubygems: 211,667,054 total
- Total docker downloads: 88,494,410
- Total dependent packages: 10 (may contain duplicates)
- Total dependent repositories: 26,346 (may contain duplicates)
- Total versions: 101
- Total maintainers: 3
gem.coop: ruby-macho
A library for viewing and manipulating Mach-O files in Ruby.
- Homepage: https://github.com/Homebrew/ruby-macho
- Documentation: http://www.rubydoc.info/gems/ruby-macho/
- Licenses: MIT
- Latest release: 6.0.0 (published about 1 month ago)
- Last Synced: 2026-08-16T00:01:10.207Z (1 day ago)
- Versions: 41
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 105,833,527 Total
- Docker Downloads: 44,247,205
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.228%
- Downloads: 0.281%
- Docker downloads count: 0.631%
- Maintainers (3)
-
Funding:
- https://github.com/sponsors/Homebrew
rubygems.org: ruby-macho
A library for viewing and manipulating Mach-O files in Ruby.
- Homepage: https://github.com/Homebrew/ruby-macho
- Documentation: http://www.rubydoc.info/gems/ruby-macho/
- Licenses: MIT
- Latest release: 6.0.0 (published about 1 month ago)
- Last Synced: 2026-08-16T00:01:10.202Z (1 day ago)
- Versions: 41
- Dependent Packages: 10
- Dependent Repositories: 26,346
- Downloads: 105,833,527 Total
- Docker Downloads: 44,247,205
-
Rankings:
- Dependent repos count: 0.219%
- Downloads: 0.336%
- Docker downloads count: 0.871%
- Dependent packages count: 1.745%
- Average: 1.855%
- Stargazers count: 3.772%
- Forks count: 4.188%
- Maintainers (3)
-
Funding:
- https://github.com/sponsors/Homebrew
proxy.golang.org: github.com/Homebrew/ruby-macho
- Homepage:
- Documentation: https://pkg.go.dev/github.com/Homebrew/ruby-macho#section-documentation
- Licenses: mit
- Latest release: v6.0.0+incompatible (published about 1 month ago)
- Last Synced: 2026-08-16T00:02:13.285Z (1 day ago)
- Versions: 9
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 3.434%
- Forks count: 3.769%
- Average: 6.895%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
proxy.golang.org: github.com/homebrew/ruby-macho
- Homepage:
- Documentation: https://pkg.go.dev/github.com/homebrew/ruby-macho#section-documentation
- Licenses: mit
- Latest release: v6.0.0+incompatible (published about 1 month ago)
- Last Synced: 2026-08-16T00:01:25.110Z (1 day ago)
- Versions: 9
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 3.434%
- Forks count: 3.769%
- Average: 6.895%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
gentoo-portage: dev-ruby/ruby-macho
A library for viewing and manipulating Mach-O files in Ruby
- Homepage: https://github.com/Homebrew/ruby-macho
- Documentation: https://packages.gentoo.org/packages/dev-ruby/ruby-macho
- Licenses: MIT
- Latest release: 4.1.0 (published 4 months ago)
- Last Synced: 2026-05-27T02:50:07.824Z (3 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- benchmark-ips >= 0 development
- codecov >= 0 development
- minitest >= 0 development
- overcommit >= 0 development
- rake >= 0 development
- rubocop >= 0 development
- ast 2.4.2
- benchmark-ips 2.10.0
- childprocess 4.1.0
- codecov 0.6.0
- docile 1.4.0
- iniparse 1.5.0
- json 2.6.2
- minitest 5.16.2
- overcommit 0.59.1
- parallel 1.22.1
- parser 3.1.2.0
- rainbow 3.1.1
- rake 13.0.6
- regexp_parser 2.5.0
- rexml 3.2.5
- rubocop 1.31.2
- rubocop-ast 1.19.1
- ruby-progressbar 1.11.0
- simplecov 0.21.2
- simplecov-html 0.12.3
- simplecov_json_formatter 0.1.4
- unicode-display_width 2.2.0
- actions/checkout main composite
- ruby/setup-ruby v1 composite
- actions/stale 5f858e3efba33a5ca4407a664cc011ad407f2008 composite
- actions/checkout 08c6903cd8c0fde910a37f88322edcfb5dd907a8 composite
- ruby/setup-ruby d5126b9b3579e429dd52e51e68624dda2e05be25 composite
- rubygems/release-gem 1c162a739e8b4cb21a676e97b087e8268d8fc40b composite
- Homebrew/actions/setup-homebrew main composite
- actions/checkout 1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 composite
- actions/download-artifact 018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 composite
- actions/upload-artifact 330a01c490aca151604b8cf639adc76d48f6c5d4 composite
- github/codeql-action/upload-sarif fdbfb4d2750291e159f0156def62b853c2798ca2 composite
- ruby *
Score: 28.117404047408474