rcmdnk / homebrew-file

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

vscode extensions #286

Open mettavi opened 2 months ago

mettavi commented 2 months ago

When running brew bundle dump vscode extensions are included in the Brewfile (see attachment).

Is there an option within brew-file to do the same?

Thanks for the great app!

Screenshot 2024-09-21 at 8 08 43 PM
rcmdnk commented 2 months ago

Thanks for raising this issue! I haven't checked Bundler recently, but it would be great if we could support what it offers. Since I haven't used VSCode before, I'm not familiar with how its extensions are managed, but I'll look into how we can implement this functionality in brew-file.

mettavi commented 2 months ago

Thanks so much for the reply. I haven't tested it yet, but it seems that brew bundle can natively dump and install vscode extensions.

Thanks so much for looking into it!

rcmdnk commented 1 month ago

VSCode extention management was implemented at v9.1.0, in additions to Whalebrew image management.

It is disabled by default.

To enable VSCode extension management, set environmental variables:

export HOMEBREW_BREWFILE_VSCODE=1

By enabling it, brew file init will add to Brewfile like:

# VSCode extensions
vscode eamodio.gitlens
vscode ms-python.debugpy
vscode ms-python.python
vscode ms-python.vscode-pylance
vscode vscodevim.vim

If you have these settings in Brewfile, brew file install installs them. In this case, if code command (installed with VSCode) is not found, i.e. VSCode is not installed, brew install vscode is also tried.

rcmdnk commented 1 month ago

For Whalebrew:

To enable Whalebrew image management, set:

export HOMEBREW_BREWFILE_WHALEBREW=1

By enabling it, brew file init will add to Brewfile like:

# Whalebrew images
whalebrew whalebrew/wget

If you have these settings in Brewfile, brew file install installs them. In this case, if whalebrew command is not found, brew install whalebrew is also tried.

To install whalebrew image, docker must be running. If it is not running, brew-file shows warning and skip installing it.

rcmdnk commented 1 month ago

brew-wrap has wrapper functions for code and whalebrew commands, too.

Brewfile is automatically updated by such code --install-extension command by enabling wrapper functions.

mettavi commented 1 month ago

Thank you so much @rcmdnk, I'll give it a try!

mettavi commented 1 month ago

Hi @rcmdnk,

I did a brew file init, and overall it worked well, but there is one problem on macOS.

It listed all my vscode extensions correctly, but there was also an error:

# VSCode extensions
vscode '[1006/165337.991581:ERROR:codesign_util.cc(109)] SecCodeCheckValidity: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)" (-67062)'
vscode 'chrmarti.regex'
vscode 'dbaeumer.vscode-eslint'
vscode 'formulahendry.code-runner'
vscode 'ms-vscode-remote.remote-containers'
vscode 'ritwickdey.liveserver'

This is a longstanding bug with the vscode code binary on macOS.

I have found a couple of workarounds in a github thread, which work on my zsh command line, but not with brew-file. I'm not sure how much work it would be to fix this problem, especially as it is a bug which will eventually be fixed. Anyway, I just wanted to let you know about it. 😉

Thanks again for brew-file and your great support! 😊

rcmdnk commented 1 month ago

Though the problem could not be reproduced in my environment, it seems the problem generates additional stderr output but stdout output is fine (?).

In v0.9.2, stderr by code command is separated and ignored, so that SecCodeCheckValidity line should be removed.

I'm not sure how the command status is set (0 or any?) and it could make a problem.

If you find any problem with new version of brew-file, do not hesitate to let me know.

mettavi commented 1 month ago

Hi @rcmdnk, thanks so much for looking into this.

I can confirm that the error is printed to stderr. However, it appears that the exit code is 0 in both cases:

❯ code --version
[1007/124602.239992:ERROR:codesign_util.cc(109)] SecCodeCheckValidity: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)" (-67062)
1.93.1
38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
x64
❯ echo $?
0
❯ code --version 2> /dev/null
1.93.1
38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
x64
❯ echo $?
0

I upgraded to brew-file 9.1.2 with homebrew, but the version is still reported as v. 9.1.0. Also, the problem does not appear to be fixed yet:

❯ tree -L1 brew-file
brew-file
├── 9.1.2
├── install.log
├── reinstall.log
└── uninstall.log

2 directories, 3 files
❯ brew-file --version
Homebrew 4.4.0-87-g6f3935d
brew-file 9.1.0 5/Oct/2024
> tail -n10 Brewfile                                                                                                      
mas 'tipitaka_pali_reader (2.6.5)', id: 1541426949
mas 'Tomito (2.1.5)', id: 1526042938

# VSCode extensions
vscode '[1007/122619.312439:ERROR:codesign_util.cc(109)] SecCodeCheckValidity: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)" (-67062)'
vscode 'chrmarti.regex'
vscode 'dbaeumer.vscode-eslint'
vscode 'formulahendry.code-runner'
vscode 'ms-vscode-remote.remote-containers'
vscode 'ritwickdey.liveserver'

Please let me know if there are any other diagnostics you need.

Thanks again and have a great day! 😀🙏

rcmdnk commented 1 month ago

sorry, that is my mistake, the code in bin was not updated. Could you please update and try v9.1.3.

mettavi commented 1 month ago

Sure, I will when 9.1.3 is available.

rcmdnk commented 1 month ago

sorry, formula had not been updated in the main branch. Now it should be available by brew update && brew upgrade.