4

When running a script:

brownie run scripts/deploy.py --network kovan

I receive this error:

raise ValueError(f"Unable to expand environment variable in host setting: ‘{uri}’”)
ValueError: Unable to expand environment variable in host setting: ‘https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID

What am I doing wrong?

5

Typically, this means your environment variables are not set correctly, and it looks like in this case it's your WEB3_INFURA_PROJECT_ID.

You can fix it by setting the variable in your .env file and adding dotenv: .env to your brownie-config.yaml.

brownie-config.yaml:

dotenv: .env

.env:

export WEB3_INFURA_PROJECT_ID=YOUR_PROJECT_ID_HERE

Remember to save these files.

Additionally, you should be on at least brownie version v1.14.6. You can find out what version you're on with:

brownie --version

If you know how to set environment variables you might want to check if you're setting them correctly.

7
  • Hi, where do you find all the possible env variable fro brownie? I mean, How can someone know about the existance of WEB3_INFURA_PROJECT_ID? Sep 14 '21 at 13:14
  • 1
    You'll have it in your .env file. You don't want others to be able to see that file though, otherwise they could make API calls to infura. Sep 14 '21 at 18:17
  • Yes, I know, I'm asking how do you know that that KEY has a meaning for brownie, I mean, in the documentation I can't find reference to that env Key Sep 14 '21 at 18:44
  • Good question, it's built in to brownie. Check here: eth-brownie.readthedocs.io/en/v1.0.1/… Sep 14 '21 at 19:12
  • Thank you, i really have those env variable that are hidden and not documented (e.g. ETHERSCAN_TOKEN that is used to publish the source code in etherscan, it's not reported) Sep 15 '21 at 10:48
1

Sometimes it can be as simple as a typo error, such as improperly naming your files, such as "browni-config.yaml" when it should be "brownie-config.yaml".

0

I've had this error for days and have seen it posted alot online. I was simply 1 directory up from where I needed to be - I followed the Patrick Collins tutorial very closey with the addition of setting up a virtual env, so maybe others are simply having the same problem I had.

I was originally in a directory "\demos\web3 brownie" which contained a folder called "brownie" and my python virtual env files.

The script is now running when I'm in directory "\demos\web3 brownie\brownie" which contains the brownie build, script, contract directories

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.