Sublime Forum

Ctrl + b opens up npm install

#1

My build system is set to python. When I open up a python script and hit ctrl + b, it often opens up a tab “npm install” but doesn’t run the python script. This happens about 30% of the time. The other 70%, the python script runs as expected. Any ideas?

0 Likes

#2

The first thing that comes to mind is to open the console with View > Show Console (or associated key binding) and enter sublime.log_build_systems(True) to turn on build system logging.

That makes Sublime display output in the console that tells you what builds are available and which one it’s choosing. Once you turn that on, check the console when the failure case happens after you press the key.

A normal result for Python would be something like this (reformatted here for readability, but in the console it will be two lines and word-wrapped0

build: relevant build actions with scope source.python - [
    Packages/Python/Python.sublime-build#, 
    Packages/Python/Python.sublime-build#Syntax Check, 
    Packages/User/Python3.sublime-build#, 
    Packages/User/Python3.sublime-build#Syntax Check
]
build: building with previous choice

That is, you see an indication that the current file is of type source.python, and a list of all build systems that declare that they know how to handle a Python build. The list you see should always have the first two items seen here, which are part of the internal Python package; what you see after that will depend on your setup.

If you see this output, then one of the build systems shown is the one that’s doing this, and that would be the one that’s at fault. You can choose which build is used by using Tools > Build With... from the menu (in which case the log generated will say prompting to choose build action instead of building with previous choice) to pick a different build or use View Package File from the command palette to examine the contents of the files to see if one of them includes the offending command (the key should show command: build in the log if things are working as expected).

If you don’t see this output, then something is stealing the key binding and not executing the build command. In that case, sublime.log_commands(True) in the console will get Sublime to log every command that’s executed, check to see what command seems to be executed in response to the failure happening.

1 Like