Batman55's avatar
Level 32

Inability to use composer globally installed packages with Herd installed

Those of you on mac with Herd installed, how are you handling not being able to use installed packages via the composer global. I must be missing something here...

composer global require statamic/cli
statamic new my-project

obviously produces an error, it isn't aware of the composer global install since it is routed to Herd's composer installation and installing it into Herd's composer doesn't work.

zsh: command not found: statamic
0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

When using Herd on macOS, it can sometimes interfere with globally installed Composer packages because Herd manages its own PHP environment. To resolve this issue, you need to ensure that the global Composer bin directory is included in your system's PATH. Here's how you can do it:

  1. Locate the Composer global bin directory:

    First, you need to find out where Composer is installing global binaries. You can do this by running:

    composer global config bin-dir --absolute
    

    This command will output the path to the directory where Composer places global binaries, typically something like ~/.composer/vendor/bin or ~/.config/composer/vendor/bin.

  2. Add the Composer global bin directory to your PATH:

    Once you have the path, you need to add it to your shell's PATH variable. If you're using zsh, you can do this by editing your ~/.zshrc file:

    nano ~/.zshrc
    

    Add the following line to the file, replacing /path/to/composer/bin with the actual path you found in step 1:

    export PATH="$PATH:/path/to/composer/bin"
    
  3. Apply the changes:

    After editing the ~/.zshrc file, apply the changes by running:

    source ~/.zshrc
    
  4. Verify the installation:

    Now, try running the statamic command again:

    statamic new my-project
    

    If everything is set up correctly, this should work without any errors.

By ensuring that the global Composer bin directory is in your PATH, you should be able to use globally installed Composer packages even when using Herd.

1 like
Batman55's avatar
Level 32

I was able to get global composer running after much googling. @laryai 's solution was faster...

Please or to participate in this conversation.