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

Using bash from HomeBrew #307

Closed
leshik opened this issue Apr 8, 2022 · 20 comments
Closed

Using bash from HomeBrew #307

leshik opened this issue Apr 8, 2022 · 20 comments
Labels
enhancement New feature or request wontfix This will not be worked on
Milestone

Comments

@leshik
Copy link

leshik commented Apr 8, 2022

Is there any reason not to use /usr/bin/env bash instead of /bin/bash?
macOS uses an old version of bash3, and I use bash5 from HomeBrew. Some tools have completions that use complete -o nosort -o nospace -o default -F ... and nosort option doesn't work in bash3, resulting in plugins failure.

@melonamin
Copy link
Contributor

Honestly, I can't come up with a reason why not to switch to /usr/bin/env bash 🤔

@melonamin melonamin added the enhancement New feature or request label Apr 16, 2022
@melonamin melonamin added this to the 1.4.4 milestone Apr 16, 2022
@melonamin
Copy link
Contributor

Addedd a separate option in Preferences, try beta

@leshik
Copy link
Author

leshik commented Apr 17, 2022

@melonamin Doesn't work for me for some reason. I.e. the shell used is still system's bash, not the one from HomeBrew despite I have it set in system preferences.

@xilopaint
Copy link
Contributor

@melonamin Doesn't work for me for some reason. I.e. the shell used is still system's bash, not the one from HomeBrew despite I have it set in system preferences.

The latest beta build works for me.

@leshik can you post a screenshot of the dropdown menu using the following plugin?

echo 'foo'
echo '---'
echo $PATH
echo $(which bash)

@leshik
Copy link
Author

leshik commented Apr 17, 2022

@xilopaint The problem is, I can't even run any script because it fails earlier failing to load /usr/local/etc/bash-completions.d as scripts there have some features that are incompatible with Bash v3.

@xilopaint
Copy link
Contributor

What error message do you get?

@leshik
Copy link
Author

leshik commented Apr 17, 2022

@xilopaint
image

@xilopaint
Copy link
Contributor

xilopaint commented Apr 17, 2022

My bet is you're based on the wrong assumption that SwiftBar is still running the system bash. The message suggests the script expects a Terminal (maybe calling tmux?) but SwiftBar is not a Terminal. You can try disabling tab completion and running the plugin I recommended to check your actual shell.

@leshik
Copy link
Author

leshik commented Apr 18, 2022

@xilopaint There are 2 errors here, and I'm talking about the first one, i.e. nosort: invalid option name, which is resulted from an incorrect Bash version. To confirm this, I edited /usr/local/etc/bash_completion.d/ipfs-completion.bash, commented the line 5259 (which is the last one in this file), and added echo $BASH_VERSION > /tmp/bv.txt there. SwiftBar has bash(env) as a shell selected. Here are the results:

$ cat /tmp/bv.txt
3.2.57(1)-release

Meanwhile:

$ /usr/bin/env bash -c 'echo $BASH_VERSION'
5.1.16(1)-release

kdeldycke added a commit to kdeldycke/meta-package-manager that referenced this issue Apr 18, 2022
melonamin added a commit that referenced this issue Sep 19, 2022
@melonamin
Copy link
Contributor

@leshik I reworked this a bit, please try again using default as the shell in SwiftBar Preferences BETA 4

@leshik
Copy link
Author

leshik commented Sep 20, 2022

@melonamin no, not working - same issue

@melonamin
Copy link
Contributor

Can you do a quick test for me please?

Run a plugin like this(I'm on mobile, can't test it):

!#/bin/env bash

echo "Test"
echo "---"
echo $SHELL
echo $0
ps -p $$

And show me the output please.

@leshik
Copy link
Author

leshik commented Sep 20, 2022

@melonamin as I described in one of my previous comments, I can't run this script as a plugin as the actual error happens prior to any plugin being executed, this my only option was to edit the HomeBrew completion file that causes the error, and insert your code there before the command that fails. Anyway, the results are interesting:
Captura de Pantalla 2022-09-20 a la(s) 9 40 39

@melonamin
Copy link
Contributor

Ok, plz help me reproduce your setup on my end, I need to:

  1. install bash from brew brew install bash
  2. change my default shell to freshly installed bash chsh …
  3. install custom bash completions(???)
  4. It should be as broken as yours

Correct? What should I do at step 3 and what is missing?

@leshik
Copy link
Author

leshik commented Sep 20, 2022

@melonamin brew install bash ipfs (ipfs is the package whose completions cause the issue)
chsh or just set the default shell for a user in UI (Users - Advanced options)

@melonamin
Copy link
Contributor

Ok, I replicated the environment and combination of this plugin and this build seems to be working correctly on my end.

#!/usr/bin/env bash

echo "Test"
echo "---"
echo $SHELL
echo $0
ps -p $$

CleanShot 2022-09-25 at 15 03 08@2x

@leshik
Copy link
Author

leshik commented Sep 26, 2022

@melonamin I don't know how else I could help to troubleshoot this. I'm on Intel Mac if it matters (I see yours is ARM), though not sure if it makes any difference.

@leshik
Copy link
Author

leshik commented Oct 5, 2022

@melonamin while experimenting I somehow screwed the settings, and now I can't access SwiftBar UI at all (though I can see it running in processes). I tried to delete settings, plugins, and restart – but it didn't help. How can I reset SwiftBar to the default state?

@melonamin
Copy link
Contributor

Nuking ~/Library/Preferences/com.ameba.SwiftBar.plist should be enough, but here is the full list of files and folders created by SwiftBar:
CleanShot 2022-10-05 at 08 01 09@2x

@leshik
Copy link
Author

leshik commented Oct 5, 2022

@melonamin something weird is happening now with this build. The test plugin only works when the shell is set to zsh. Selecting default results in no output at all (then it's not even possible to access settings), and selecting bash draws in the bar, but now it doesn't even matter if I comment complete -o sort ... option in bash completions – it doesn't work in any case.

@melonamin melonamin modified the milestones: 1.4.4, 1.4.5 Oct 23, 2022
@melonamin melonamin added the wontfix This will not be worked on label Aug 4, 2023
@melonamin melonamin closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants