Sublime Forum

SublText 4 no output from shell "/usr/local/bin/bash" in 1500ms

#1

Jump to 4 seems really smooth! Thanks a lot for that. But a long lasting problem seems to persists there:

startup, version: 4107 osx arm64 channel: stable
executable: /Applications/Sublime Text 4.app/Contents/MacOS/sublime_text
application: /Applications/Sublime Text 4.app
working dir: /
packages path: /Users/me/Library/Application Support/Sublime Text/Packages
state path: /Users/me/Library/Application Support/Sublime Text/Local
zip path: /Applications/Sublime Text 4.app/Contents/MacOS/Packages
zip path: /Users/me/Library/Application Support/Sublime Text/Installed Packages
ignored_packages: ["All Autocomplete", "File Rename", "FileDiffs", "Filter Lines", "FilterPipes", "Focus File on Sidebar", "Gnuplot", "Indent XML", "Inline Python", "IPython Notebook", "jsonschema", "LaTeX Word Count", "Modula-2 Language Syntax", "MyCustomFilterPipes", "Origami", "PackageResourceViewer", "PyYapf Python Formatter", "rsub", "SFTP", "SideBarTools", "sublime-github", "Sublime-HTMLPrettify", "SublimeAStyleFormatter", "SublimeLinter-cppcheck", "Swift", "SyncedSideBar", "View In Browser", "Vintage"]
pre session restore time: 0.232209
OpenGL Context Information:
  GL API Version: 4.1 Metal - 71.6.4
  GLSL Version: 4.10
  Vendor: Apple
  Renderer: Apple M1
startup time: 0.289862
no output from shell "/usr/local/bin/bash" in 1500ms
first paint time: 0.294645

It doesn’t see the shell when that shell is there:

ls -l "/usr/local/bin/bash"
lrwxr-xr-x  1 me  admin  29  7 may 19:14 /usr/local/bin/bash -> ../Cellar/bash/5.1.8/bin/bash

On the other hand, I can’t find the configuration issue that makes python and C++ output (stdout, that is, print or cout) work perfectly but not Ruby, and some others, their output doesn’t appear on Console, no matter you set the "shell": false, in their sublime-build json

0 Likes

#2

The message isn’t telling you that it can’t find /usr/local/bin/bash, it’s telling you that when it tries to start bash so that it can capture your system PATH, after 1.5 seconds it gave up because bash didn’t print anything.

This is usually caused by having tasks run in your .bashrc that take some longer amount of time to complete that aren’t properly checking if the session is interactive or not (since commonly this happens to set something up that would only be useful in an interactive session).

That’s a different problem; in a sublime-build file, shell is for indicating whether the contents of cmd should be executed directly or passed to the system command interpreter (here bash) to execute.

Does that problem happen even with a simple “Hello World” type program? Can you share what the contents of your sublime-build files look like?

0 Likes

#3

Thanks!
I managed to solve the print output with Python, it was the shell: false, but with ruby it doesn’t work.
With respect to the speed of bash it doesn’t take that long when time bash echo ‘$PATH’…

0 Likes

#4

We’re talking about the time it takes to start a new shell. Open a new terminal window/re-login to see how long it takes.

ST on Mac does this because launchd doesn’t inherit a shell environment.

0 Likes

#5

Thanks. Does it mean ST expects [“Open a new terminal window”, “login in bash”, "execute ~/.bash_profile"] takes less than 1500ms and if not, it discards PATH terminal path and so…?

I have fixed, after a few tries the ruby.sublime_build

{
    "env": {
            "ST_BUILD_SHOW_OUTPUTVIEW": "true",
            "SUBLIMETEXT": "true" // to break .bash_profile
    },
    // "shell_cmd": "/usr/local/opt/ruby/bin/ruby '${file}'", // never put this!!!
    "cmd": ["/usr/bin/env", "ruby", "${file_name}"],
    "shell": false,
    "selector": "source.ruby, source.Ruby",
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "working_dir": "${file_path}"
}
0 Likes

#6

Correct. Sublime Text will launch a login shell to get the environment variables. This should not take 1.5s. If you want to load something for your terminal then that should be in your .bashrc, whereas environment variables should be in .bash_profile. A login shell only loads the profile.

0 Likes