17

I installed openvpn with brew. The installation went fine, no errors or missing dependencies. But now when I try to run it:

users-MBP:~ user$ brew install openvpn
Warning: openvpn-2.3.7 already installed
users-MBP:~ user$ openvpn
-bash: openvpn: command not found

I based myself on this tutorial: https://my.hostvpn.com/knowledgebase/29/OpenVPN-on-Mac-OS-X-via-Homebrew-CLI.html

  • Out of curiosity, why did you not choose to go with TunnelBlick? – agentroadkill Sep 2 '15 at 23:28
  • 1
    @agentroadkill After some time on Linux I have a strong preference for command-line tools over GUIs. Whenever possible I try to go for a CLI solution. – Juicy Sep 2 '15 at 23:33
  • I believe TunnelBlick is fully configurable from command line, though I rarely use it as I generally use it for simplistic end-user functions. – agentroadkill Sep 2 '15 at 23:36
  • 1
    @agentroadkill I may look into it. openvpn also has the advantage of being the same tool I used on Linux for the job so I could just copy over my configuration files, same commands etc... But I will look into TunnelBlick if I can't get it working. – Juicy Sep 2 '15 at 23:44
  • TunnelBlick is just an OpenVPN client for MacOS. Any OpenVPN config generated for Linux and/or Windows can be used with it. – agentroadkill Sep 2 '15 at 23:46
12

At the terminal type:

echo $PATH 

That's your default search path for executables. Looks like the openvpn executable was installed someplace not in your search path.

First, you'll need to find the openvpn executable:

sudo find / -type f -name "openvpn" 

Then add the directory containing the openvpn executable to your default search path by adding this sort of line to the end of your .profile (in your home directory, a.k.a. /Users/yourusername/.profile:

export PATH="/some/brew/dir:$PATH"
  • 7
    brew info openvpn is faster – igor Nov 16 '16 at 23:44
25

Add this to your ~/.bash_profile:

export PATH=$(brew --prefix openvpn)/sbin:$PATH
  • 6
    You won my heart – Lo-Tan Nov 27 '17 at 16:23
6

You have to add /usr/local/sbin to your path.

It was installed to /usr/local/sbin but that directory is not in your $PATH by default. Add a line like this to your ~/.bashrc or equivalent:

export PATH=/usr/local/sbin:$PATH
  • This is the best fix, but the best, permanent way to make the fix it is to edit /etc/paths and add /usr/local/sbin to it (more info here) – Mike Beaton Jan 16 at 9:34
3

In my case:

  1. Installation using homebrew

    brew install openvpn

  2. Information regarding binaries

    brew info openvpn

  3. It gave me installation path as:

    /usr/local/Cellar/openvpn/2.4.0

  4. Then I browsed for bin directory but found executable inside sbin. So, I added following line

    export PATH=$PATH:/usr/local/Cellar/openvpn/2.4.0/sbin

in my ~/.zshrc file as well as in ~/.bash_profile file using a text editor.

Worked Flawlessly, After a workaround for an hour :)

1

I was having same issue today and I had to do sudo brew services start openvpn

0

You can also add a symlink from usr/local/sbin into usr/local/bin like so:

cd /usr/local/bin
ln -s ../sbin/openvpn .
0

Brew now link the openvpn binary. reinstall it using

brew reinstall openvpn

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .