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

EDITOR not respected #95

Closed
cipri-tom opened this issue Nov 20, 2020 · 5 comments
Closed

EDITOR not respected #95

cipri-tom opened this issue Nov 20, 2020 · 5 comments

Comments

@cipri-tom
Copy link

Thanks for making this much needed manager !

I've just started using it.
When I do brew file edit it always open up vim, although I have set EDITOR=nano.

I believe it is related to this line:

self.opt["my_editor"] = os.environ.get("EDITOR", "vim")

But I'm not sure how to stop the program to debug why the environ call doesn't see the EDITOR variablel. Can you please indicate where the source file is located after installation, so that I can help debug this?

Thanks again !

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 20, 2020

Thanks for reporting.
The problem was reproduced at my environment, too.

It works if you call brew-file directly:

$ brew-file edit

then nano is launched if you set export EDITOR=nano.

But it seems Homebrew resets some environment variables when it calls subcommands,
though some variables like HOMEBREW_BREWFILE works even at brew file.

I will check it.

@cipri-tom
Copy link
Author

Thank you ! Great fast response

So brew file is just a convenience over brew-file ?

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 20, 2020

Yes, if you have any executables named brew-XXX in your PATH,
then you can call it by brew XXX (as same as for git command).

But as you saw, there seems some differences which I've not noticed.

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 29, 2020

I found that brew normally loads only specific variables:

https://github.com/Homebrew/brew/blob/ef755182bbd11bf8f49b0139d089046596ab8fb7/bin/brew#L89

EDITOR is not loaded.

If you set:

export HOMEBREW_NO_ENV_FILTERING=1

then all variables will be loaded and EDITOR work for brew file edit.

I don't know what will be wrong with HOMEBREW_NO_ENV_FILTERING=1 , but maybe anything is not suitable for specific cases.

On the other hand, brew loads all HOMEBREW_XXX variables.
Therefore, variables for brew-file (HOMEBREW_BREWFILE_XXX are also valid.

Then, I added HOMEBREW_BREWFILE_EDITOR option.
If you set

export HOMEBREW_BREWFILE_EDITOR=nano

then nano will be used even for brew file edit.

Another option is to use brew-wrap.
If you wrap brew command by brew-wrap,
then brew file edit will be changed to brew-file edit directly,
and EDITOR option is also valid.
To enable it, just add

if [ -f $(brew --prefix)/etc/brew-wrap ];then
  source $(brew --prefix)/etc/brew-wrap
fi

in your .bashrc or .zshrc.

Home one of them works for you!

@cipri-tom
Copy link
Author

All of them work !
I hadn't used brew-wrap when first installing, but I do now and it works "by default". Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants