tailscale: macOS brew package does not start

What is the issue?

I just installed tailscale with brew install tailscale to try out Tailscale Funnel but the Tailscale service fails to start.

When running brew services I get the following output:

tailscale error  256 sebastian ~/Library/LaunchAgents/homebrew.mxcl.tailscale.plist

Checking the logs with cat /opt/homebrew/var/log/tailscaled.log

tailscaled requires root; use sudo tailscaled (or use --tun=userspace-networking)

Trying to enable the service with sudo privileges doesn’t work either. Is this a known error?

Steps to reproduce

brew install tailscale
tailscale up

Are there any recent changes that introduced the issue?

Not sure.

OS

macOS

OS version

13.3

Tailscale version

1.38.3

Other software

No response

Bug report

N/A

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 18 (2 by maintainers)

Most upvoted comments

What’s worked in my testing is to NOT do the brew install under sudo:

# Do NOT use `sudo` here:

brew update
brew install --formula tailscale

But then do the remaining commands under sudo:

# Now use `sudo` for the remaining commands:

sudo brew services start tailscale
sudo tailscale up
sudo tailscale status

Thanks for the information. I’ve updated the snippet above. the -c stands for changes, it print in case it has changed any permissions. I have GNU utils in my $PATH from /opt/homebrew/opt/coreutils/libexec/gnubin and GNU coreutils’s chown support -c as well as allow for arguments to be at any position, unlike BSD chown that MacOS uses by default.

Here’s how it looks with GNU chown:

piotr@sabre ~ % sudo chown ${USER}:admin -Rc /opt/homebrew/Cellar/tailscale/ /opt/homebrew/opt/tailscale /opt/homebrew/var/homebrew/linked/tailscale
changed ownership of '/opt/homebrew/Cellar/tailscale/1.58.2/bin/tailscaled' from root:admin to piotr:admin
changed ownership of '/opt/homebrew/Cellar/tailscale/1.58.2/bin' from root:admin to piotr:admin
changed ownership of '/opt/homebrew/opt/tailscale' from root:admin to piotr:admin
changed ownership of '/opt/homebrew/var/homebrew/linked/tailscale' from root:admin to piotr:admin

To fix this, I did this:

  1. Copied and modified the startup file at /opt/homebrew/opt/tailscale/homebrew.mxcl.tailscale.plist and placed it at /Library/LaunchDaemons/com.tailscale.tailscaled.plist

  2. Then, do this:

    brew services stop tailscale
    sudo launchctl load -w /Library/LaunchDaemons/com.tailscale.tailscaled.plist
    

Now tailscaled starts correctly.

The modified plist looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.tailscale.tailscaled</string>
    <key>ProgramArguments</key>
    <array>
      <string>/opt/homebrew/opt/tailscale/bin/tailscaled</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>root</string>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/opt/homebrew/var/log/tailscaled.log</string>
    <key>StandardErrorPath</key>
    <string>/opt/homebrew/var/log/tailscaled.log</string>
  </dict>
</plist>

I think it is on the brew side to deal with it however I feel like getting this done would require tohe official tailscale client here to have some guideliness how to run it as a headless daemon on MacOS system. I much prefer the brew-installed tailscale CLI over the GUI variant.

My solution has been to install and update tailscale with brew as normal (i.e. not using sudo) and then follow the instructions from Tailscale in the section ‘Run the tailscaled (daemon)’. Seems to work well and then there’s no issue with messed up permissions in my homebrew installation.

The result of it is brew not working well after that.

Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /opt/homebrew
Permission denied @ rb_readlink - /opt/homebrew/opt/tailscale
Error: Permission denied @ rb_readlink - /opt/homebrew/opt/tailscale

Which means after running brew services start as root you need to bump back privileges to your own user, otherwise it will simply not work for other apps.

For people that might come in here from web search, the best so far way to handle it I found is

brew install tailscale
sudo brew services start tailscale
sudo chown -R ${USER}:admin /opt/homebrew/Cellar/tailscale/ /opt/homebrew/opt/tailscale /opt/homebrew/var/homebrew/linked/tailscale

And repeat the last step every time you use brew services with sudo (start/stop/restart after upgrade).

EDIT: Updated the snippet above to work with BSD chown.

What a nightmare to get this working 😄 @ksylvan solution worked for me, thanks!

For me, only brew services needs to be executed with sudo:

$ sudo brew services start tailscale
Warning: Taking root:admin ownership of some tailscale paths:
  /opt/homebrew/Cellar/tailscale/1.56.1/bin
  /opt/homebrew/Cellar/tailscale/1.56.1/bin/tailscaled
  /opt/homebrew/opt/tailscale
  /opt/homebrew/opt/tailscale/bin
  /opt/homebrew/var/homebrew/linked/tailscale
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
Warning: tailscale must be run as non-root to start at user login!
==> Successfully started `tailscale` (label: homebrew.mxcl.tailscale)

This is not ideal though (as the message indicates), but it should unblock folks.