Skip to content

Incorrect bin directory for M1 Macs #1023

@jasonvarga

Description

@jasonvarga

Clear description of your problem

Homebrew added support for M1 Macs. As part of that, they're now using /opt/homebrew rather than /usr/local.

Valet still uses the old path in its code.

This causes a couple of issues:

  • The valet binary doesn't get symlinked into the user's bin
  • Valet constantly asks for your password because the path in the sudoers file that valet trust generates points to the wrong place.

Expected behavior

  • The path to the correct bin directory should be used.
  • The valet binary should get symlinked to the correct bin directory.
  • The valet trust command should write the correct path and stop asking for passwords.

Steps to Reproduce

  1. Fresh install of MacOS on an M1 mac.
  2. Install Homebrew
  3. Install Valet
  4. Run valet trust
  5. Open a new terminal so your sudo doesn't carry over from a second ago.
  6. Run a valet command, see that it asks for your password.
  7. Symlink /opt/homebrew/bin/valet
  8. Edit /etc/sudoers.d/valet to point to /opt/homebrew/bin/valet
  9. New terminal again.
  10. Run a valet command, but this time it won't ask for a password.

Possible solution

The path is hardcoded here:

var $valetBin = '/usr/local/bin/valet';

This'll probably need to be injected.

I imagine it'll need to be a bit more than a "is this an M1, use /opt/homebrew, otherwise /usr/local" because of people that installed Homebrew before the native M1 support, which still would have used /usr/local.

Maybe you can check if the /opt/homebrew directory exists?

There's a few other references to /usr/local. https://github.com/laravel/valet/search?q=%2Fusr%2Flocal

I'm happy to take a stab at a PR when I get time, but I don't know when that'll be. Maybe this will be a simple thing for someone who knows Valet's internals better.

Hope that was helpful, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions