leapp: Leapp doesn't detect AWS CLI in newer homebrew locations

Describe the bug

Leapp seems to only search for the AWS CLI in /usrl/local/bin.

Leapp Version 0.11.0

To Reproduce Steps to reproduce the behavior:

  1. Obtain a new M1 Mac 😃
  2. Install Homebrew
  3. Install AWS CLI va Homebrew (brew install awscli)
  4. Install Leapp
  5. Launch Leapp

Expected behavior

Leapp should detect alternative locations of the AWS CLI or allow me to configure the location. The new homebrew path is /opt/homebrew/bin. Although, it’s probably best for Leapp to search PATH for the command.

Screenshots Screen Shot 2022-04-15 at 17 53 50

Desktop (please complete the following information):

  • macOS 12.3.1
  • Leapp 0.11.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 11
  • Comments: 15 (10 by maintainers)

Most upvoted comments

just create a soft link

sudo ln -s /opt/homebrew/bin/aws /usr/local/bin/aws

and don’t forget to install the Session Manager too

Yes, we can remove it, I think. Thanks for the suggestion

Thanks @josemiguel. I did the following and it worked for me.

sudo ln -s /opt/homebrew/bin/aws /usr/local/bin/aws
sudo ln -s /opt/homebrew/bin/session-manager-plugin /usr/local/bin/session-manager-plugin

I noticed that the red warning now includes a link with instructions on how to create a symlink. By the way, the instructions would be clearer if they contained a typical example.

Then, after I created the link, I was surprised to see another similar-looking red warning that on closer inspection was telling me about the session-manager-plugin, even though I don’t use the session-manager-plugin, and this time the link did not explain how to create a symlink.

The following worked with my brew-installed utils:

cd /usr/local/bin
ln -s $(which aws) aws
ln -s $(which session-manager-plugin) session-manager-plugin

Some digging through the code… It seems like it’s trying to guess the absolute path of the binaries instead of relying on the $PATH of the default shell to resolve it.

https://github.com/Noovolari/leapp/blob/e11df16679792f62e9d24fc15acfdc8baacedd82/packages/desktop-app/src/app/components/tray-menu/tray-menu.component.ts#L238-L241

https://github.com/Noovolari/leapp/blob/e11df16679792f62e9d24fc15acfdc8baacedd82/packages/desktop-app/src/app/components/tray-menu/tray-menu.component.ts#L253-L256

https://github.com/Noovolari/leapp/blob/e11df16679792f62e9d24fc15acfdc8baacedd82/packages/core/src/services/execute-service.ts#L23-L43

A few ways to solve it

  1. Rely solely on the $PATH env var of the default shell. Works for all commands.
  2. Use a which command to find the location of the binary. Works for most commands except for cd which is built-in to the shell.
  3. Use brew --prefix which returns /opt/homebrew on M1 to find the /bin prefix to better guess the path. Would work better but would maintain the brittleness of the current logic.