Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to get build systems to use default shell #1734

Closed
1 of 3 tasks
ghost opened this issue May 28, 2017 · 23 comments
Closed
1 of 3 tasks

option to get build systems to use default shell #1734

ghost opened this issue May 28, 2017 · 23 comments

Comments

@ghost
Copy link

ghost commented May 28, 2017

Summary

when building java or ruby or c code I get errors (see actual behavior)
...

Expected behavior

no errors should be raised
...

Actual behavior

/usr/local/share/bash-completion/bash_completion: line 1897: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/usr/local/share/bash-completion/bash_completion: line 2060: complete: -D: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
~/.bash_profile: line 154: shopt: autocd: invalid shell option name
[Finished in 1.1s]

...

Steps to reproduce

things I have setup, that work correctly for themselves, but may be a source of the sublime issues

  1. installed bash 4.4 via home-brew
  2. added /usr/local/bin to my path, because of home-brew

my best guess is that sublime is using the default bash 3 but bash 3 with my current bash_profile only gives me one error __git_ps1: command not found

Environment

  • Operating system and version:
    • Windows ...
    • Mac OS ...
    • Linux ...
  • Sublime Text:
    • Build 3126

thanks for any help!

@ghost
Copy link
Author

ghost commented May 28, 2017

so I found other people having the same issue and the shell was not added to their /etc/shells and csh was no performed

I did both and all is working as expected in my terminal so maybe I just need to know how sublime reads which bash to use, is there some sublime specific variable I can export?

thanks

@ghost
Copy link
Author

ghost commented May 28, 2017

https://stackoverflow.com/a/33092219

this script works for me (all the others don't)
https://stackoverflow.com/a/32960744

but hopefully this could be made happen by default for all default built systems?

launchctl getenv /usr/local/bin/bash
is set as well

thanks

@ghost
Copy link
Author

ghost commented May 28, 2017

if I create a new build file like this
https://github.com/sublimehq/Packages/blob/master/Java/JavaC.sublime-build

but use
cmd instead of shell_cmd and set "shell":true it works as expected

any idea what is going on?

@keith-hall
Copy link
Collaborator

You might want to try build 3127 or newer from https://www.sublimetext.com/3dev - the changelog shows:

OS X: the user's default shell is executed and environmental variables are set in the plugin Python environment

more details on how ST does that here.

@ghost
Copy link
Author

ghost commented May 29, 2017

ok I tried 3132 (actually just finally purchased)

still gives the same error though :/

@keith-hall
Copy link
Collaborator

Further investigation shows that ST's build command is currently hardcoded (in Packages/Default/exec.py) to execute /bin/bash on MacOS.
https://forum.sublimetext.com/t/sublime-text-3-to-use-zsh-shell/13729

@ghost
Copy link
Author

ghost commented May 29, 2017

ok thanks sounds like this could be the issue
so I would have to do this? https://forum.sublimetext.com/t/sublime-text-3-to-use-zsh-shell/13729/8?u=14b56

don't really want to though...

any chance that this will get changed? or is this considered to be an edge case?

thanks for the quick response!

@FichteFoll
Copy link
Collaborator

FichteFoll commented May 30, 2017

So to conclude, you want ST to use a different shell (bash 4 in /usr/local/bin instead of bash3 in /bin/bash) for executing your command, correct?

Could you include your sample build file in the report?

@ghost
Copy link
Author

ghost commented May 30, 2017

yes this is correct

the default built scripts do give me this error

{
	"shell_cmd": "ruby \"$file\"",
	"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
	"selector": "source.ruby"
}

from https://github.com/sublimehq/Packages/blob/master/Ruby/Ruby.sublime-build
gives an error

{
    "cmd": "ruby ${file}",
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.ruby",
    "shell": true
}

works fine (by which I mean: it does not give an error, I don't know if it actually uses bash4 or bash3)

woking default options would be nice because they apply automatically and don't require changing 👍

@wbond
Copy link
Member

wbond commented Jun 1, 2017

We generally don't use the user's preferred shell for build systems because that will almost certainly lead to issues. Instead, on Linux and OS X we always run /bin/bash for consistency.

It seems in this case perhaps your bash_profile or bashrc was trying to use bash features not supported by /bin/bash on your machine.

I'm not sure there is an answer to this that won't break things for some users.

@ghost
Copy link
Author

ghost commented Jun 1, 2017

It seems in this case perhaps your bash_profile or bashrc was trying to use bash features not supported by /bin/bash on your machine.

sure

We generally don't use the user's preferred shell for build systems

could there be an option to force it nevertheless? Building in bash 4 works great. I'm fine with /bin/bash being the default but there should a better option than temporally hacking sublime source

the issue has quite a few views (2k) on your forum as well and the issue is also applicable for zsh users I guess

if you would consider this option it would really be nice

@ghost
Copy link
Author

ghost commented Jun 9, 2017

Is there any news/ opinion on that?
I tried all options suggested in the sublime forum (editing source file/ using plugin) but none worked :/

@wbond
Copy link
Member

wbond commented Jun 9, 2017

It sounds like an enhancement request that can get added to the list the next time I work on build systems.

@wbond
Copy link
Member

wbond commented Jun 9, 2017

If you want to have your system use /usr/local/bin/bash, try out https://packagecontrol.io/packages/PackageResourceViewer to properly override Default/exec.py with your edits.

https://packagecontrol.io/packages/OverrideAudit can help you ensure you don't miss updates and bug fixes to exec.py in the future.

@ghost
Copy link
Author

ghost commented Jun 9, 2017

I tried that already but it would not show any results on "exec.py" so I uninstalled it, now, if I open search through the installable Packages it won't even find PackageResourceViewer
(I am on 3134)

(found out that TextMate has a feature to set a specific Path but well does not help much)

@keith-hall keith-hall changed the title bash options not accepted option to get build systems to use default shell Jun 15, 2017
@ghost
Copy link
Author

ghost commented Jul 28, 2017

S:trival ?

is there still any chance getting this fixed?
thanks

@wbond
Copy link
Member

wbond commented Jul 28, 2017

We haven't been working on build systems recently. Since this isn't a bug, but an enhancement, it will probably be bundled with some related work on build systems.

@ghost
Copy link
Author

ghost commented Jul 30, 2017

ok, good to know it is in your list

@keith-hall keith-hall added this to the Build 3153 milestone Nov 1, 2017
@keith-hall
Copy link
Collaborator

Build 3153 has the following change to fix this:

Build systems: Use /usr/bin/env to locate bash

@ghost
Copy link
Author

ghost commented Nov 1, 2017

I still get

~/.bash_profile: line 62: bind: warning: line editing not enabled
~/.bash_profile: line 63: bind: warning: line editing not enabled
~/.bash_profile: line 65: bind: warning: line editing not enabled

because of

bind 'set show-all-if-ambiguous on'
bind 'TAB:menu-complete'

bind -x '"\C-l": clear'

but this is certainly MUCH better than before

THANKS

@ghost
Copy link
Author

ghost commented Nov 1, 2017

according to this

sublime output reports to be "interactive" thus the if else on bash_profile does not work (strange thing is: ambiguous completion with the guarded profile does not work in normal terminal either)

maybe there is an "easy" bash setting/ fix I'm just missing

@ghost
Copy link
Author

ghost commented Nov 11, 2017

subl_var=`tty`

if [[ $subl_var != "not a tty" ]] ; then
    bind 'set show-all-if-ambiguous on'
    bind 'TAB:menu-complete'
    bind -x '"\C-l": clear'
fi

works and output is now perfectly clean and readable, nice!

@Alyetama
Copy link

In case someone googles and find this, you can easily use a default shell by adding a custom shell_environment key in your Preferences file. For example, to invoke zsh:

"shell_environment": "/bin/zsh",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants