Valet: open command not consistent with terminal equivalent

Created on 11 Nov 2016  路  11Comments  路  Source: laravel/valet

After looking at the code for the open command, I can't see why this would happen, but right now if I run valet open from a site's directory it always opens in Safari. However, if I run open the-url.dev it will open in Chrome (my default browser). I would expect these two to be consistent (and open Chrome). I can't put my finger on exactly when this changed.. perhaps after upgrading to Sierra?

Like I said, I don't know that valet is to blame here, but perhaps someone else is having the same problem?

Laravel Valet version 1.1.22

Most helpful comment

@ericvanjohnson it absolutely is an issue related to sudo.. try running open http://some-url and then sudo open http://some-url the latter will open in safari because safari is the 'default browser' for the root user. The bottom line is, the command shouldn't be running via sudo at all, but it absolutely does -- at least on macos sierra.

I've done the digging, and the testing.. the PR just needs to be merged.

All 11 comments

Here's the valet command:

/**
 * Open the current directory in the browser.
 */
 $app->command('open', function () {
     $url = "http://".Site::host(getcwd()).'.'.Configuration::read()['domain'].'/';
     passthru("open ".escapeshellarg($url));
 })->descriptions('Open the site for the current directory in your browser');

For your non-valet open command, if you add http:// to open the-url.dev like: open http://the-url.dev does it give a different result?

Sorry, I meant open https://the-url.dev.

open the-url.dev doesn't work as it looks for a file by that name.

I have seen the code for the command there, and like I said I can't see why it wouldn't be consistent.

Having the same issue.

Looks like @willvincent nailed it in #198 and also supplied a pull request to fix it.

@remailednet I don't see how @willvincent PR addresses this issue. The fact that safari is opening when you type valet open isn't an issue with a sudo command.

@ericvanjohnson it absolutely is an issue related to sudo.. try running open http://some-url and then sudo open http://some-url the latter will open in safari because safari is the 'default browser' for the root user. The bottom line is, the command shouldn't be running via sudo at all, but it absolutely does -- at least on macos sierra.

I've done the digging, and the testing.. the PR just needs to be merged.

@willvincent I stand corrected. I pulled in your patch and it does address that issue. Thanks for the fix. Does have me a little concerned that I've been letting a script run commands as sudo which I assumed I knew what it was doing.

Thanks again.

@taylorotwell _this_ is the main issue my PR resolved.

https://github.com/laravel/valet/pull/206

Was this or the pull request #206 being reconsidered?
I find that valet open using safari is a pain point that I find myself simply avoiding the terminal or using valet beyond the initial setup of a site.

@taylorotwell or @adamwathan this is annoying, please reconsider #206 if that is indeed the fix.

Just noticed this was fixed by the merge of #396! 馃憤 馃挴

Was this page helpful?
0 / 5 - 0 ratings