How to set environment variables so that brew will compile with my environment

Hi, I’ve been using brew for a long time but this is the first time I needed to set up environment variables for a specific installation. Unfortunately I can’t find a way for brew to use my shell environment variables, trying HOMEBREW_MYVAR didn’t help either, and setting the variable with ruby didn’t work too. I searched the documentation and the forum with no success. See for instance the following shell when I was experimenting with the ways I thought of to set a variable:

$ ruby -e 'p ENV["MAKEFLAGS"]'
$ brew --env

If I remember it right, you can’t pass environment variables from command line - you should use brew sh --env to get into build environment shell.

I found a way to use my environment, by setting the env parameter like below

brew instal --env=std

But then I ask, why doesn’t brew use the std environment for default?

See for the explanation. When you want to maximize the “just works” rate for millions of users with unique environments, nailing down the build environment is pretty much mandatory.

Then for those users who are sophisticated enough and want things their ways, there’s --env=std.

My original post should have been more explanatory. I decided that I had too much packages installed and then removed brew to have a fresh start. Indeed brew just worked before I deleted it. Now it doesn’t work anymore. I made another post asking a question derived from this post.

What I am trying to do is to understand why a newly installed brew does not use the paths in my system, to the point where it does not include the headers in the system Frameworks and will not even compile git. When I asked about the default environment is because I was led to believe that std means the default. Now, no matter what environment I use, I have a broken brew installation, no matter how many times I reinstall it. I am putting a lot of effort in trying to understand why, believe me.