Search code examples
sublimetext2build-system

HTML Build system in Sublime Text 2


I'm struggling to successfully build a HTML build system in Sublime Text 2. I am running Windows 7. This is the code for my build system:

{
    "cmd": ["open", "-a", "Google Chrome", "$file"]
}

This is the error I recieve when I try and build a html file:

[WinError 2] The system cannot find the file specified
[cmd: ['open', '-a', 'Google Chrome', 'C:\\Users\\Soham\\Desktop\\hello.html']]
[dir: C:\Users\Soham\Desktop]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem]
[Finished]

I have no idea why this error is ocurring and have searched the web for an explanation.

Any help will be much appreciated!

Thanks in advance!


Solution

  • The open command is only available on OSX systems. You have two options - you can use Sublime's built-in "Open in Browser" functionality by right-clicking in any open HTML file and selecting Open in Browser, or you can modify your build system to just point to the correct location of chrome.exe:

    "cmd": [ "C:\\Users\\YourUserName\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe", "$file"]
    

    replacing YourUserName with the correct value, and ensuring that this actually is the location of chrome.exe on your system.