Magento - using "mage" command line tool locally

Magento - using "mage" command line tool locally

September 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - using "mage" command line tool locally

Solving the Magento Mage Command Line Tool Issue Locally

Hello everyone! Today, I want to address a common issue that many Magento developers face when trying to use the mage command line tool on their local machine.

The Problem: Mage Chokes When Invoking a Channel

When setting up a Magento installation on your local machine, you might find that the mage command fails when you try to invoke it with a channel specified. For instance, running a simple download command like this:

./mage download community Namespace_Module

Could result in an error message such as:

Error:
download: Uri doesn't contain host part

This issue occurs because the mage tool relies on parsing the URL of the specified channel to extract the necessary components for processing. However, something goes wrong when this happens locally.

Understanding the Mage Tool’s Code

The mage tool is essentially a PHP script that uses the built-in parse_url function to split the channel URL into its parts—scheme, host, port, path, query, fragment, and authority. If any of these components are missing or malformed, it throws an error.

One common reason for this issue is if your local environment doesn’t have a proper base URL set up in Magento’s configuration files (e.g., MAGE_URL in the .htaccess file).

Steps to Resolve the Issue

Here are some steps you can take to troubleshoot and resolve this problem:

1. Check Your Localhost Configuration

Ensure that your local server is properly configured with a valid base URL. If you’re using XAMPP or WAMP, the default base URL should be http://localhost.

2. Verify Your Magento Installation

Make sure your local Magento installation was set up correctly and that all necessary files are in place.

3. Test the Mage Command with a Different Channel

Try running the command with a different channel to see if the issue persists. For example:

./mage download partners Namespace_Module

If this works, the problem might be with your community channel configuration or URL.

4. Check Your SVN Repository

If you’re using SVN for version control, ensure that all necessary files and directories are properly checked out and synced across your local machine and remote servers.

A Workaround: Using Pear Command Line Tool

While we’re still working on a definitive solution to this issue, a temporary workaround is to use the old pear command line tool. After running the pear command to install the module, you can then use svn status to extract the downloaded package pieces into your local system’s organization.

Please note that this is far from an ideal solution and we’re actively seeking a more elegant way to handle this situation.

Conclusion

In summary, when facing the “Uri doesn’t contain host part” error while using the mage command line tool on your local machine, double-check your base URL configuration, verify your Magento installation, and try running the command with different channels. If all else fails, you can use the pear command as a temporary workaround until we find a more permanent solution.

Remember to keep an eye out for updates on this issue and feel free to share any insights or findings that could help us resolve it once and for all!

Happy coding!

Back to our Magento guide at Laravel Company

Database Extensions Configuration Errors

Our network