Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the Windows PATH from a Sublime Text 3 Python build error?

I am using Python 3 on Sublime Text 3 (win8.1 64bit). When I write some code and then build, if there is an error, the Windows PATH is displayed as part of the error.

How do I remove the Windows PATH on Sublime Text 3 output when there is an error?

I wont to remove ==> I want to erase.

like image 909
Jimmy Avatar asked Apr 13 '16 23:04

Jimmy


People also ask

How do I edit a build in Sublime Text 3?

sublime-build , and it will now be accessible in the build system menu. Select it, hit Ctrl B to build, and then hit Ctrl Shift B to run the resulting program. Or you can use a Build and Run option and call it by hitting Ctrl B , then selecting that option. I Am doing that.

How do I delete a system in Sublime Text 3?

Go to Preferences -> Browse Packages. Then click User and delete your build system.

How do I fix Python not found in Sublime Text?

sublime-build program is trying to execute python as a command, but it's not able to find it on the path, so Windows generates an error. If you add the appropriate path to python.exe to your PATH environment variable (and restart Sublime), that problem should go away.

How do I find the build system in Sublime Text?

Sublime Text is able to run build programs such as 'make', either when a key in pressed (F7 by default), or when a file is saved. The build system to use can be select from the Tools/Build System menu. If a project is open, the selected build system will be remembered for the project.


1 Answers

This behavior can be changed by commenting out four specific lines in Packages/Default/exec.py, which is the system file that runs build systems by default.

First, you'll need to install PackageResourceViewer from Package Control. Next, open the Command Palette with CtrlShiftP and type in prv to bring up the PackageResourceViewer options. Select PackageResourceViewer: Open Resource, then Default, then exec.py. You can now hit Esc to clear the Command Palette.

In the open file, scroll down to approximately line 212, looking specifically for this code block:

if "PATH" in merged_env:
    self.debug_text += "[path: " + str(merged_env["PATH"]) + "]"
else:
    self.debug_text += "[path: " + str(os.environ["PATH"]) + "]"

Select all 4 lines, then comment them out by hitting Ctrl/. Finally, hit CtrlS to save the file.

This will create a new Default folder in your Packages directory (the one opened by selecting Preferences -> Browse Packages...) with exec.py inside, and will override the original file stored in Default.sublime-package, which is stored elsewhere, in Sublime's installation directory. If at any time you wish to have the full PATH printed again, simply open Packages/Default/exec.py and uncomment the lines you commented before, then save the file.

I would also recommend deleting exec.py and re-running through the procedure above every time you upgrade Sublime, as there may be vital changes to this file in the new release that are key for other parts of the build systems to work.

like image 161
MattDMo Avatar answered Oct 07 '22 15:10

MattDMo