Valet: Running Valet causes "sudo: illegal option -- -"

Created on 10 Jul 2019  ยท  6Comments  ยท  Source: laravel/valet

When I try to run "valet install" I get this:

sudo: illegal option -- -
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g
            groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid]
            [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...

i tried to uninstall and reinstall valet via composer but nothing changes...

Most helpful comment

If anyone like me is stuck with Mac OS 10.11 or below and find Valet throwing this error, it is simply because of incompatibilities with the usage of sudo that changed in Mac OS 10.12.

The easiest "fix" is to just change the source of /usr/local/bin/valet and edit the line that has --preserve-env and replace it with the old switch -E.

Hope that helps any random Googlers.

All 6 comments

What's the output of the following?

sw_vers
valet --version
cat ~/.config/valet/config.json
ls -al /etc/sudoers.d/

The following is less likely related, but may be of diagnostic help:

openssl version -a
openssl ciphers
php -v
which php
which -a php
nginx -v
brew config
brew doctor
brew info openssl
brew info nginx
brew info php
sudo nginx -t

sw_vers:

ProductName:    Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F2511

valet --version

sudo: illegal option -- -
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...

cat ~/.config/valet/config.json
cat: /Users/blabla/.config/valet/config.json: No such file or directory

ls -al /etc/sudoers.d/
ls: /etc/sudoers.d/: No such file or directory

openssl version -a

OpenSSL 1.0.2k  26 Jan 2017
built on: reproducible build, date unspecified
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: cc -I. -I.. -I../include  -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/local/php5/ssl"

php -v

PHP 7.2.19 (cli) (built: Jun 22 2019 10:25:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.19, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans

which php
/usr/local/php5/bin/php

which -a php

/usr/local/php5/bin/php
/usr/local/bin/php
/usr/bin/php

nginx -v
nginx version: nginx/1.17.1

brew config

HOMEBREW_VERSION: 2.1.7-10-g1798ded
ORIGIN: https://github.com/Homebrew/brew
HEAD: 1798deda057c409cc13b9e85a6f88419713db0a3
Last commit: 14 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 9bde298f7be331ef87744c21b4007807a186ec03
Core tap last commit: 14 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
CPU: quad-core 64-bit broadwell
Homebrew Ruby: 2.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/bin/ruby
Clang: 7.0 build 700
Git: 2.22.0 => /usr/local/opt/git/bin/git
Curl: 7.43.0 => /usr/bin/curl
Java: 1.6.0_65-b14-468
macOS: 10.10.5-x86_64
CLT: 7.2.0.0.1.1447826929
Xcode: 7.2.1

brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /usr/local/php5/bin/curl-config
  /usr/local/php5/bin/freetype-config
  /usr/local/php5/bin/icu-config
  /usr/local/php5/bin/iodbc-config
  /usr/local/php5/bin/libmcrypt-config
  /usr/local/php5/bin/libpng-config
  /usr/local/php5/bin/libpng12-config
  /usr/local/php5/bin/php-config
  /usr/local/php5/bin/xslt-config

Warning: You are using macOS 10.10.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience, as you are running this old version.

brew info openssl

openssl: stable 1.0.2s [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2s (1,787 files, 12.1MB)
  Built from source on 2019-07-10 at 09:49:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
==> Caveats

brew info nginx

nginx: stable 1.17.1, HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.17.1 (10 files, 2.1MB) *
  Built from source on 2019-07-10 at 11:49:59
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb
==> Dependencies
Required: openssl โœ”, pcre โœ”
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Analytics
install: 35,237 (30 days), 109,013 (90 days), 437,332 (365 days)
install_on_request: 33,608 (30 days), 103,059 (90 days), 405,287 (365 days)
build_error: 0 (30 days)

brew info php

php: stable 7.3.7
General-purpose scripting language
https://www.php.net/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/php.rb
==> Dependencies
Build: httpd โœ˜, pkg-config โœ”
Required: apr โœ”, apr-util โœ”, argon2 โœ˜, aspell โœ˜, autoconf โœ”, curl-openssl โœ˜, freetds โœ˜, freetype โœ˜, gettext โœ”, glib โœ˜, gmp โœ”, icu4c โœ˜, jpeg โœ˜, libpng โœ˜, libpq โœ˜, libsodium โœ˜, libzip โœ˜, openldap โœ˜, openssl โœ”, sqlite โœ”, tidy-html5 โœ˜, unixodbc โœ˜, webp โœ˜
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.3/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Analytics
install: 38,482 (30 days), 110,382 (90 days), 457,463 (365 days)
install_on_request: 34,942 (30 days), 100,091 (90 days), 412,683 (365 days)
build_error: 0 (30 days)

sudo nginx -t

nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/Users/blabla/.valet/Log/nginx-error.log" failed (2: No such file or directory)
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

One more thing:

I was not able to install php 7.2 with brew install:

Installing [email protected] dependency: nghttp2
==> Downloading https://github.com/nghttp2/nghttp2/releases/download/v1.39.1/nghttp2-1.39.1.tar.xz
Already downloaded: /Users/blabla/Library/Caches/Homebrew/downloads/6984bdcfb74df16853cef4581cfbd2ac12eae3599221018e98280c0ea3199aae--nghttp2-1.39.1.tar.xz
==> ./configure --prefix=/usr/local/Cellar/nghttp2/1.39.1 --disable-silent-rules --enable-app --disable-python-bindings --with-xml-prefix=/usr --disable-threads
==> make
Last 15 lines from /Users/blabla/Library/Logs/Homebrew/nghttp2/02.make:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:2547:9: note: candidate constructor [with _Up = shrpx::Http2DownstreamConnection, _Ep = std::__1::default_delete<shrpx::Http2DownstreamConnection>] not viable: no known conversion from 'std::__1::unique_ptr<shrpx::Http2DownstreamConnection, std::__1::default_delete<shrpx::Http2DownstreamConnection> >' to 'unique_ptr<shrpx::Http2DownstreamConnection, std::__1::default_delete<shrpx::Http2DownstreamConnection> > &&' for 1st argument
        unique_ptr(unique_ptr<_Up, _Ep>&& __u,
        ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:2562:35: note: candidate template ignored: could not match 'auto_ptr' against 'unique_ptr'
        _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p,
                                  ^
1 error generated.
make[3]: *** [libnghttpx_a-shrpx_client_handler.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/libnghttpx_a-shrpx_http2_upstream.Tpo .deps/libnghttpx_a-shrpx_http2_upstream.Po
mv -f .deps/libnghttpx_a-shrpx_https_upstream.Tpo .deps/libnghttpx_a-shrpx_https_upstream.Po
mv -f .deps/libnghttpx_a-shrpx_config.Tpo .deps/libnghttpx_a-shrpx_config.Po
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!


Error: You are using macOS 10.10.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience, as you are running this old version.

So I install it with this method:
[I](https://php-osx.liip.ch/

I am able to "php artisan serve" and see laravel homepage @ http://127.0.0.1:8000/

I udpate my OSX from 10.10 to 10.12 and it works :)

If anyone like me is stuck with Mac OS 10.11 or below and find Valet throwing this error, it is simply because of incompatibilities with the usage of sudo that changed in Mac OS 10.12.

The easiest "fix" is to just change the source of /usr/local/bin/valet and edit the line that has --preserve-env and replace it with the old switch -E.

Hope that helps any random Googlers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sadhakbj picture sadhakbj  ยท  3Comments

dustinleblanc picture dustinleblanc  ยท  4Comments

idmahbub picture idmahbub  ยท  3Comments

hsleewis picture hsleewis  ยท  5Comments

dannygsmith picture dannygsmith  ยท  5Comments