vitr-archive / valet4windows

Windows version of Laravel Valet
MIT License
63 stars 5 forks source link

Windows cannot find .bat file on valet start #6

Closed mauroavello closed 8 years ago

mauroavello commented 8 years ago

Hi Vitaliy, Unfortunately, after installing valet it tells me that it cannot find the start.bat file. The error reads:

Windows cannot find .bat. Make sure you've typed the name correctly, then..

I've gone through the process a few times, but no luck so far.

Running windows 10 w/ git bash as administrator

error

Thanks a lot for your time

mauroavello commented 8 years ago

Hi Vitaliy, I got it working; sort of.

  1. I had to do valet start under Composer's valet4windows directory .
  2. Then I had to rename the .env.example to .env
  3. And finally, had to generate the key via artisan.

I don't know if valet does points 2 and 3 by itself. My guess is that it does. At least for the time being I got it working for the time being. If you can look into it, it would be of great help.

Thanks

vitr commented 8 years ago

hi @mauroavello , 2 and 3 are definitely not valet's job, it only serves stuff, doesn't change anything inside linked folders. did you install valet globally? e.g composer global require vitr/valet4windows also can you check the actual valet location with where valet and post the output here, thanks

mauroavello commented 8 years ago

I think I messed up somewhere as I have two: C:\Users\myuser\AppData\Roaming\Composer\vendor\bin\valet C:\Users\myuser\AppData\Roaming\Composer\vendor\bin\valet.bat

Thanks for the quick reply

vitr commented 8 years ago

can you manually start the C:\Users\myuser\AppData\Roaming\Composer\vendor\bin\valet.bat ? as a quick fix, you can make a shortcut for that file and start it manually (that was what I did in the beginning). If you're comfortable with debugging php you can print something on every step of the valet start command. c:\Users\Vit\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\valet.php line#238 this is where actual valet start happens. I mean, you can see what is different when you run it from valet4windows and somewhere else. I can only reproduce your issue when I manually remove my start.bat

mauroavello commented 8 years ago

@vitr Ok, so it works if I execute the bat file directly.

I've tried digging into it a bit more and these are a few things that I found:

'mystart.bat' is not recognized as an internal or external command,
operable program or batch file

It seems to me that there is something wrong on how the string is parsed. It might be the mix of windows and linux style paths??

C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\
start "Valet" cmd.exe @cmd /k "cd 

and for the $cmd variable:

C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\/../ && mystart.bat"Valet services have been started.

Again, I don't know if the forward and backward slashes are messing things up. Thanks

vitr commented 8 years ago

thanks @mauroavello , you've brought a very valuable point, I should change the path to make the same slashes start "Valet" cmd.exe @cmd /k "cd C:\Users\Vit\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\..\ && start.bat" but this make no difference for me, as I'm running c:\Program Files\Git\git-bash.exe which, I guess, understands both styles of slashes. may I ask you to find out what is your version of git-bash ( I believe they had Git\bin\sh.exe before)? and can you also run bash --version, my version, just for the reference, is

$ bash --version
GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)

I notice, you have a slightly different icon as you can see, I bet, we're running different git-bash versions image 2 Would you try to change line #238 in c:\Users\Vit\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\valet.php to

$cmd = 'start "Valet" cmd.exe @cmd /k "cd '.VALET_BIN_PATH.'..\ && start.bat"';

and see if it helps. Really appreciate your help.

mauroavello commented 8 years ago

@vitr A few things:

D:\codeprograms\Git

I'm also thinking that it could also be the way Git does line endings. In my installation I have as follows: image image image image

As for the line change it didn't work for me. I'll be reinstalling git-bash to see if there are any changes to the configuration.

Thanks

vitr commented 8 years ago

oh, man, this is it, I use MinTTY, that mac stuff does't work in windows cmd.exe image 3 perhaps I should include this in the requirements, if you can try MinTTY and see if it helps

mauroavello commented 8 years ago

I've tried with different configs:

'mystart.bat' is not recognized as an internal or external command,
operable program or batch file.

Sorry @vitr but the MinTTY that didn't work for me either...

Would this work under Windows-Ubuntu?

vitr commented 8 years ago

but it should be start.bat not mystart.bat

mauroavello commented 8 years ago

Sorry, yes I know. But as I mentioned before if I leave start.bat it complains that it can't find .bat, not start.bat. As start is a command it seems that it doesn't like it. Do you use start.bat in any other place??

vitr commented 8 years ago

I just tried the second option cmd.exe instead of MinTTY, and it still works for me, yeah, it must be something else... start.bat is a file, the script just cd to the folder and run that file valet start is the package command that initiates the above command

vitr commented 8 years ago

there is no magic, let's try to run this command in your shell

start "Valet" cmd.exe @cmd /k "cd C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\..\ && start.bat"

and you can split it to smaller pieces like

start "Valet" cmd.exe 
start "Valet" cmd.exe @cmd /k "cd C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\..\"

and find the cause of the issue

mauroavello commented 8 years ago

Hi @vitr I get cmd.exe not defined: image

vitr commented 8 years ago

ha, I know what it is)) sorry, this time you have to open actually cmd.exe (the windows standard shell) and run

start "Valet" cmd.exe @cmd /k "cd C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\..\ && start.bat"

because start in git-bash is different, sorry for the confusion))

mauroavello commented 8 years ago

Ok, so from the command line this is what works for me:

start "Valet" &&cmd @cmd /i/k "cd /d C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\..\ && mystart.bat"

Note the

It works but it opens two command windows.

I hope this is of some help...

vitr commented 8 years ago

@mauroavello ok, /i and /d are valuable options, but the first && doesn't make any sense, as I'm launching a new cmd window with the title "Valet" cd /d, I guess, fixes the issue if you run valet from other then C: drive. I actually was able to reproduce your initial issue if I didn't have the /d option. could you try then this

start "Valet" cmd.exe /i/k "cd /d C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\..\..\bin\..\ && start.bat"

which is working OK for me, with only one window has been opened (it's inevitable as caddy is not a service). So, in the command we'are starting new cmd window with 2 switches:

  1. /i Passes the Cmd.exe startup environment to the new Command Prompt window.
  2. /k tells CMD.exe to open, run the specified command, then keep the window open

Then inside the new cmd we change directory (and possible drive thanks to \d switch) and run the start.bat

mauroavello commented 8 years ago

Sorry @vitr but the command line that you mention still gets me the Symfony error I mentioned before. Not only that but for some reason browserSync only responds to changes in the views. At this point I think I might try to find a simple server-browserSync solution that works as I only want to use this to test out ideas.

vitr commented 8 years ago

sorry for this, you've already done some great tests and found some real issues, I'll address in the next release. if you have some time, can ask you to run very basic command just in standard windows cmd.exe

start "Valet" cmd.exe

to confirm that we're on the same page, as I suspect (because of the Symfony error) that shell tries to run valet instead of opening new cmd window.

mauroavello commented 8 years ago

@vitr I really want to thank you for your patience and the fact that you've taken the time to release this to the community. Unfortunately, at this time I don't have that much time for debbuging. Indeed, I might be an edge case. When I finish this project I will try to come back to this. As you mentioned the

start "Valet" cmd.exe

returns a Symfony error. The only way it works for me is if I do:

start "Valet" &&cmd @cmd /i/k "cd /d C:\Users\mauro\AppData\Roaming\Composer\vendor\vitr\valet4windows\cli\includes\.
.\..\bin\..\ && mystart.bat"

but this way I open two windows.

When I have a bit more time I might try to run it under the Ubuntu/Windows shell and see how that goes.

Thanks again for your time

vitr commented 8 years ago

obviously it is some edge case, start "Valet" cmd.exe should just open new cmd window, nothing more, basic windows cmd operation. you could try start "NewCmdWindowName" cmd.exe to confirm this. please, feel free to reopen, if you have time and interested in hunting this bug down.

mauroavello commented 8 years ago

@vitr. Went back to reinstalling and now its working. Updated to PHP 7.0.10, but I don't think that's the cause. In any case thank you so much for your patience and work.

vitr commented 8 years ago

@mauroavello really glad to know this, thanks for your feedback, appreciate it.