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

The plugin does not work properly if we change the destination of the homebrew installation #28

Closed
intptr-t opened this issue Feb 23, 2022 · 3 comments · Fixed by #30
Closed
Labels
bug Something isn't working enhancement New feature or request

Comments

@intptr-t
Copy link

intptr-t commented Feb 23, 2022

If we have changed the installation destination of homebrew, unable to find limactl.
Is there any better solution?

What's happening

Exception

exit status 1: Traceback (most recent call last):
  File "./lima-plugin", line 600, in <module>
    main()
  File "./lima-plugin”, line 578, in main
    xbarMenu()
  File "./lima-plugin", line 556, in xbarMenu
    vms = listVMs()  
  File "./lima-plugin”, line 256, in listVMs
    vmRaw = subprocess.run(
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'limactl'

image

xbar or swiftbar starts the plugin with PATH as follows:

PATH=/usr/bin:/bin:/usr/sbin:/sbin

My installation directory of homebrew:

% brew --prefix
/Users/${USER}/homebrew

lima-xbar-plugin cannot call limactl because brew --prefix cannot be used.

Temporary workaround

Add the homebrew/bin path directly to extrapaths

extrapaths = ["/usr/local/bin", "/opt/homebrew/bin", "/opt/local/bin", "/Users/${USER}/homebrew/bin"]

Expected results

The path of homebrew/bin is automatically resolved and limactl can be called.
Then xbar or swiftbar will not generate any errors.

@unixorn
Copy link
Owner

unixorn commented Feb 23, 2022

Where is brew itself installed on your installation? The code needs to be able to run brew --prefix to find the bin directory.

@intptr-t
Copy link
Author

I followed the instructions Alternative Installs to install it.

And I have installed the brew itself in the following directory

% which brew
/Users/${USER}/homebrew/bin/brew

@unixorn
Copy link
Owner

unixorn commented Feb 24, 2022

Custom brew locations are going to be a hassle to deal with automatically. I'll have to add a menu item that lets you set/unset the location of brew, but it's going to have to be a manual process - I can't anticipate all the locations people might stash their brew install in.

That said, sticking it in the home directory seems like it's the most likely alternate location, so I'll add that as one of the default places to search.

This would be a lot easier if macOS gui apps picked up stuff like $PATH from the shell's login environment, but I understand why they don't go that route.

@unixorn unixorn added bug Something isn't working enhancement New feature or request labels Feb 24, 2022
unixorn added a commit that referenced this issue Feb 27, 2022
- Check for `~/homebrew/bin` and `~/homebrew/sbin` to cope when homebrew
  is installed in a user's home directory. Closes #28
- While we're in there, check for `/usr/local/sbin`,
  `/opt/homebrew/sbin`, `/opt/local/sbin`, `~/bin` and `~/sbin`
  directories too.

Signed-off-by: Joe Block <jpb@unixorn.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants