Programming

Homebrew list available versions with new formulaversion format

19 September 2026 · 10 min read

Homebrew list available versions with new formulaversion format

Homebrew, the popular package manager for macOS, simplifies the installation of software not provided by Apple. Managing software dependencies and ensuring compatibility can be a headache, but Homebrew streamlines this process, making it easier to install, update, and manage command-line tools, graphical applications, and more. As software evolves, having access to specific versions becomes crucial, especially when dealing with legacy projects or maintaining consistent environments. This guide explores how to effectively manage different versions of software using Homebrew’s new formula@version format. We’ll delve into the nuances of installing, switching, and pinning specific versions to ensure a smooth development experience. Understanding these techniques is essential for any macOS user leveraging Homebrew for software management.

Understanding Homebrew’s Formula@Version Syntax

Homebrew’s formula@version syntax offers a precise way to specify the exact version of a package you wish to install. This is particularly useful when newer versions introduce breaking changes or when compatibility with older projects is paramount. Instead of relying on the default, often latest, version, you can explicitly define the version needed. The syntax is straightforward: simply append @ followed by the desired version number to the formula name. For example, to install Node.js version 14, you would use brew install node@14. This method ensures you get the exact version you need, preventing unexpected issues related to software updates.

Before using the formula@version syntax, it’s essential to understand how Homebrew handles multiple versions. While you can install different versions, only one version of a formula can be linked as the active version at any given time. This means that when you run a command associated with the formula (e.g., node), it will default to the linked version. To switch between versions, you might need to use commands like brew switch or manually adjust your PATH environment variable. Always check the Homebrew documentation for the most up-to-date instructions and best practices. According to Homebrew’s official documentation, using specific versioned formulas is crucial for reproducibility in development environments [^1^].

Consider a scenario where you’re working on two projects: one requiring Python 3.8 and another requiring Python 3.9. With formula@version, you can install both versions using brew install python@3.8 and brew install python@3.9. However, you’ll need to use brew switch python 3.8 or brew switch python 3.9 to activate the desired version for each project. Alternatively, tools like virtualenv and pyenv can further isolate these environments, ensuring each project uses its designated Python version without conflicts. This highlights the importance of understanding how to manage multiple versions to avoid dependency clashes.

Listing Available Versions of a Formula

Before installing a specific version using the formula@version syntax, you need to know which versions are available. Unfortunately, Homebrew doesn’t provide a direct command to list all available versions for a formula. However, you can achieve this by exploring the Homebrew core repository on GitHub. Each formula has a corresponding file in the Homebrew/homebrew-core repository, which contains the version history. By examining the Git history of that file, you can identify all the versions that have been available for that formula.

To find the formula file on GitHub, search for the formula name within the Homebrew/homebrew-core repository. Once you locate the file, view its history to see the different versions that have been committed. Each commit typically corresponds to a version update. Note that this method requires some familiarity with Git and navigating GitHub repositories. Alternatively, community-maintained resources and third-party tools might offer easier ways to list available versions. Always verify the source and reliability of these tools before using them. For example, you can use git log --pretty="%h %ad %s" --date=short Formula/<formula_name>.rb</formula_name> in the homebrew-core repository to see the commit history [^2^].

For instance, if you want to find available versions of node, you’d search for “node” in the Homebrew/homebrew-core repository on GitHub. The file will be named node.rb. By viewing the commit history of this file, you’ll see entries like “node: update to version 16.10.0,” which indicates that version 16.10.0 was once available. This manual process can be tedious, but it provides a reliable way to determine the historical versions of a formula. Keep in mind that not all versions may be available due to various reasons such as deprecation or removal from the repository.

Installing and Switching Between Versions

Once you’ve identified the desired version, installing it with formula@version is straightforward. Use the command brew install formula@version, replacing “formula” with the name of the package and “version” with the specific version number. For example, to install Redis version 5, you would run brew install redis@5. Homebrew will then download and install the specified version. However, remember that only one version can be actively linked at a time.

Switching between installed versions requires using the brew switch command. The syntax is brew switch formula version. For instance, to switch to Redis version 5 after installing it, you would use brew switch redis 5. This command updates the symbolic links to point to the specified version, making it the active version. If you encounter issues with brew switch, ensure that both versions are properly installed and that there are no conflicting configurations. Sometimes, you might need to manually unlink and relink the versions to resolve conflicts. Before switching, back up any important configurations or data associated with the formula to prevent data loss.

Consider a scenario where you need to test your application against different versions of PHP. You can install multiple PHP versions using brew install php@7.4 and brew install php@8.0. Then, use brew switch php 7.4 or brew switch php 8.0 to switch between the versions as needed. Remember to restart your web server or PHP-FPM after switching versions to ensure the changes take effect. This approach allows you to easily test compatibility and identify any version-specific issues. Managing these versions effectively is a core skill for any web developer [^3^].

Pinning and Unpinning Formula Versions

Pinning a formula version prevents Homebrew from automatically upgrading it when you run brew upgrade. This is useful when you need to maintain a specific version for compatibility reasons or to avoid breaking changes introduced in newer releases. To pin a formula, use the command brew pin formula. For example, to pin Node.js, you would run brew pin node. Once pinned, Homebrew will ignore updates for that formula unless you explicitly unpin it.

To unpin a formula and allow it to be upgraded, use the command brew unpin formula. For example, to unpin Node.js, you would run brew unpin node. After unpinning, the formula will be included in the next brew upgrade, potentially updating it to the latest version. It’s important to carefully consider the implications of pinning and unpinning, as it can affect the stability and compatibility of your environment. Always test upgrades in a development environment before applying them to production systems.

Imagine you’re working on a legacy project that relies on a specific version of Ruby. To prevent accidental upgrades, you can pin the Ruby version using brew pin ruby. This ensures that the project continues to function as expected, even when you update other packages on your system. When you’re ready to upgrade Ruby, perhaps after testing the project with a newer version in a separate environment, you can unpin it using brew unpin ruby and then run brew upgrade ruby. This controlled approach minimizes the risk of introducing breaking changes. This is a critical practice for maintaining stable development environments.

  • Pin formulas to prevent unwanted upgrades.
  • Use brew upgrade carefully after unpinning.

Troubleshooting Common Issues

When working with formula@version, you might encounter issues such as installation failures, conflicts between versions, or problems with the brew switch command. One common cause of installation failures is that the specified version is no longer available in the Homebrew repository. In such cases, double-check the version number and ensure it’s a valid version that was previously available. Another potential issue is conflicts between different versions of the same formula. To resolve these conflicts, try unlinking the existing version before installing the new one. You can use the command brew unlink formula to unlink the current version.

If you experience problems with the brew switch command, ensure that both versions are properly installed and that there are no conflicting configurations. Sometimes, you might need to manually unlink and relink the versions to resolve conflicts. If a formula refuses to switch, you may need to manually edit your PATH environment variable to ensure the correct version’s binaries are being accessed. This involves modifying your shell configuration file (e.g., .bashrc, .zshrc) to include the correct path to the desired version’s binaries. Remember to restart your terminal after making changes to your PATH variable.

For example, if you’re having trouble switching between different versions of Python, you might need to manually adjust your PATH variable to point to the correct Python executable. This involves adding or modifying lines in your .zshrc or .bashrc file to include the path to the desired Python version’s bin directory. Always back up your configuration files before making changes, and be careful not to introduce syntax errors that could prevent your shell from starting correctly. Consult online resources and community forums for troubleshooting tips specific to your configuration and the formula you’re working with.

  • Verify the version number is correct.
  • Check and resolve any conflicting configurations.
Infographic here: A visual guide to Homebrew version management commands.
Here's a featured snippet-optimized paragraph: Managing different versions of software with Homebrew is crucial for developers working on multiple projects or maintaining legacy systems. Homebrew's `formula@version` syntax allows you to install specific versions of packages, ensuring compatibility and preventing unexpected issues. To install a specific version, use the command `brew install formula@version`, replacing "formula" with the package name and "version" with the desired version number. Remember to switch between versions using `brew switch` or adjust your PATH environment variable.
  1. Identify the required version.
  2. Install the version using brew install formula@version.
  3. Switch to the version using brew switch formula version.
  4. Pin the version to prevent automatic upgrades if needed.

Explore more Homebrew tips and tricksFAQ

How do I check which version of a formula is currently installed?
You can use the command `brew list --versions formula` to see the installed versions of a specific formula.
Can I have multiple versions of the same formula installed simultaneously?
Yes, Homebrew allows you to install multiple versions of the same formula, but only one version can be actively linked at a time.
What happens if I try to install a version that is no longer available?
Homebrew will display an error message indicating that the specified version cannot be found in the repository.
How do I update all my Homebrew packages except for the pinned ones?
Simply run `brew upgrade`. Pinned packages will be skipped during the upgrade process.
Is it possible to revert to a previous version of a formula after upgrading?
Yes, you can use the `formula@version` syntax to install the previous version and then switch to it using `brew switch`.
Mastering Homebrew's version management capabilities empowers you to create stable and reproducible development environments. The ability to install, switch, and pin specific versions ensures compatibility and prevents unexpected issues related to software updates. By understanding the `formula@version` syntax and utilizing the techniques outlined in this guide, you can confidently manage your software dependencies and maintain a consistent workflow. Take the time to explore the available versions of your commonly used tools and experiment with different configurations to find what works best for your projects. Dive deeper into Homebrew's documentation and community resources to further enhance your skills.

Why not put these version management techniques into practice today? Start by listing the available versions of your most used Homebrew formulas, then try installing and switching between them. Pin those critical versions that keep your projects running smoothly. Embrace the power of precise software control and watch your productivity soar.