rcmdnk / homebrew-file

Brewfile manager for Homebrew
http://homebrew-file.readthedocs.io/
MIT License
356 stars 29 forks source link

Cannot be used `brew install` #108

Closed yanskun closed 3 years ago

yanskun commented 3 years ago

brew install / uninstall command not working

for example

$ brew install git
  File "/usr/local/bin/brew-file", line 86
    for kk in [f"${k}", f"${{{k}}}"]:
                     ^
SyntaxError: invalid syntax

/usr/local/bin/brew-file is read-only. So I haven't edited it.

versions

$ brew config
HOMEBREW_VERSION: 3.2.17-71-g033c365
ORIGIN: https://github.com/Homebrew/brew
HEAD: 033c365b0da986efd8e5b7e14111e19afa6bdccf
Last commit: 8 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: c8ae85dcacff92efd0ebd95a362d33355907c610
Core tap last commit: 65 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/bin/ruby
CPU: octa-core 64-bit kabylake
Clang: 12.0.0 build 1200
Git: 2.33.1 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 10.15.7-x86_64
CLT: 12.4.0.0.1.1610135815
Xcode: 12.3

tried

$ brew uninstall brew-file
  File "/usr/local/bin/brew-file", line 86
    for kk in [f"${k}", f"${{{k}}}"]:
                     ^
SyntaxError: invalid syntax

This error prevents you from even uninstalling.

please help me...

rcmdnk commented 3 years ago

I will check later.

For now, to avoid the problem, try:

Even if you sourced the brew-wrap, you can call brew command directly with command:

$ command brew install git
rcmdnk commented 3 years ago

Could you check:

$ brew file version

before uninstalling brew-file?

rcmdnk commented 3 years ago

I could reproduce the error when I tried:

$ python2 /usr/local/bin/brew-file 
  File "/usr/local/bin/brew-file", line 86
    for kk in [f"${k}", f"${{{k}}}"]:

So, somehow brew command used python2.

Could you please check followings?:

$ /usr/local/bin/brew-file

This should show just an usage.

$ brew-file

Should same as above

$ type brew

I think it uses brew-wrap.

$ type python3

This should be like /usr/local/bin/python3 or some python3.

yanskun commented 3 years ago

I'm using python3.

$ brew file
  File "/usr/local/bin/brew-file", line 86
    for kk in [f"${k}", f"${{{k}}}"]:
                     ^
SyntaxError: invalid syntax

$ pyenv versions
  system
  3.10.0
* 3.5.10 (set by ...)

$ pyenv install 2.7.18
$ pyenv global 2.7.18
$ python --version
Python 2.7.18
$ brew file
usage: brew-file [-f INPUT] [-b BACKUP] [-F FORM] [--leaves] [--on_request]
                 [--top_packages TOP_PACKAGES] [-U] [-r REPO] [-n] [--caskonly]
                 [--appstore APPSTORE] [--no_appstore] [-C] [-y] [-V VERBOSE] [-h]
                 [command] ...

Execute `brew-file help` to get help.

Refer https://homebrew-file.readthedocs.io for more details.

$ brew install git
Updating Homebrew...
...

I was able to confirm that there is no problem if I downgrade the python version from 3 to 2.

The problem is resolved!

thank you very much!!!!


I'm using pyenv installed with anyenv to version control python.

@rcmdnk

Is it incompatible?

yanskun commented 3 years ago

It worked when I tried to use python2.x

rcmdnk commented 3 years ago

OK, I understand.

The main problem is that the python you used does not have f-string function. It is introduced in Python 3.6. Python3.5 (and Python2.X) does not have it.

When you set pyenv global 2.7.18, there was no python3 in your virtual environment. Then, the script called python3 of the system (maybe /usr/local/bin/python3, installed by homebrew (python3.9)).

Current homebrew-file needs python3.6 or later and it is automatically installed by homebrew when homebrew-file is installed.

If you need to work with python3.5 or former, you need to run brew command outside of the virtual environment or remove brew-wrap lines from your .bashrc/.zshrc.