firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firebase CLI installation fails if directory /usr/local/bin doesn't exist.

Open jotae85 opened this issue 6 years ago • 4 comments

[REQUIRED] Environment info

firebase-tools: doesn't apply

Platform: macOS

[REQUIRED] Test case

Installation of Firebase CLI fails on macOS if the directory /usr/local/bin doesn't exist.

Workaround: create missing directory manually.

mkdir /usr/local/bin
curl -sL https://firebase.tools | bash

[REQUIRED] Steps to reproduce

Make sure the the directory /usr/local/bin doesn't exist. Run curl -sL https://firebase.tools | bash

[REQUIRED] Expected behavior

Firebase is installed successfully

[REQUIRED] Actual behavior

Firebase installation fails. Output:

-- Checking for existing firebase-tools on PATH...
-- Checking your machine type...
[Binary URL] https://firebase.tools/bin/macos/latest
-- Downloading binary...
######################################################################## 100.0%#=#=#                                      ######################################################################## 100.0%#-#O=#  #                                  ######################################################################## 100.0% #-#O=#   #                                Warning: Failed to create the file /usr/local/bin/firebase: No such file or 
Warning: directory
                                                                           0.0%
curl: (23) Failed writing body (0 != 16360)
-- Setting permissions on binary...
chmod: /usr/local/bin/firebase: No such file or directory
bash: line 213: firebase: command not found
Something went wrong, firebase has not been installed.
Please file a bug with your system information on Github.
https://github.com/firebase/firebase-tools/
-- All done!

jotae85 avatar May 20 '20 10:05 jotae85

Relates to: https://github.com/firebase/firebase-tools/issues/2019

mieliespoor avatar May 21 '20 11:05 mieliespoor

So regardless of platform (WSL or specific linux distros) /usr/local/bin might not exist. This is really crummy because it's very difficult to know where we should be installing to, obviously as root we could just place the binary to the first folder in PATH but that seems... sketch. The fix mentioned in this bug, creating /usr/local/bin is not going to work everywhere cause that issue only comes up if the developer is missing the folder but it's still somehow on their PATH which seems... unlikely.

On top of that, we also have no way of knowing which directory is appropriate if it's not the /usr/local/bin. If we look at the logs from #2019 we know that that user had PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/.dotnet/tools:/root/bin so it looks like they were running as root and so if we placed the binary on /usr/local/sbin it would work for root but you can get into a situation where the binary is now only present for root (which could be the result of sudo) so as soon as they're out of the sudo they wont see the firebase command. Terrible.

So the solution I suggest is to create /usr/local/bin since this directory is standard on 95% of *nix distros and check if it's on the PATH if it isn't, we'll finish the install but then exit out and tell the developer that the install was successful but the directory isn't on your path and link them to this SO post which explains how to add a directory to your PATH. This way we're not trying to guess directories and we can inform the user how to fix their system in the event of a missing folder / incomplete PATH

abeisgoat avatar Jun 02 '20 17:06 abeisgoat

Some feedback from the situation in our case. We have the path /usr/local/bin existing, but the user don't have access to it. What we doing now is to install firebase as root and then run chown afterwards to ensure that our user will own the /usr/local/bin/firebase. This is working quite well and we are able to move forward with have firebase on our hosted build agents again.

mieliespoor avatar Jun 09 '20 21:06 mieliespoor

Restarting my computer (Ubuntu) solved the issue.

munjata avatar Jul 01 '21 15:07 munjata