brownie: ValueError: Unable to expand environment variable in host setting
Environment information
- eth-brownie>=1.10.0,<2.0.0
ganache-cliVersion: 6.12.2solcVersion: 0.6.6- Python Version: 3.8.5
- OS: linux (ubuntu 20.04)
What was wrong?
Please include information like:
-
what command you ran
brownie run scripts/simple_collectible/deploy_simple.py --network rinkeby -
the code that caused the failure (see this link for help with formatting code)
-
full output of the error you received
NftMixProject is the active project.
File "brownie/_cli/__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "brownie/_cli/run.py", line 43, in main
network.connect(CONFIG.argv["network"])
File "brownie/network/main.py", line 40, in connect
web3.connect(host, active.get("timeout", 30))
File "brownie/network/web3.py", line 51, in connect
uri = _expand_environment_vars(uri)
File "brownie/network/web3.py", line 171, in _expand_environment_vars
raise ValueError(f"Unable to expand environment variable in host setting: '{uri}'")
ValueError: Unable to expand environment variable in host setting: 'https://rinkeby.infura.io/v3/$WEB3_INFURA_PROJECT_ID'
How can it be fixed?
Fill this in if you know how the bug could be fixed.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 53 (14 by maintainers)
So I ran into this issue while I was doing
test_lottery_unit.pyof @PatrickAlphaC 's tutorial.This might help you guys. Add this to the script
I also ran into this issue running
brownie test -k test_get_entrance_fee --network rinkebysolved by adding
dotenv: .envtobrownie-config.yamlLooks like this is from the new
.envfile improvement. https://eth-brownie.readthedocs.io/en/stable/config.html?highlight=.env#dotenvIt’s not pulling in env variables at the project level, so I can’t use the
.envvariables in my project, only in my yaml. Is this the intended effect? I’m running into the same issue.You can run
source .envbefore you run thebrownie run scripts/get_weth.py --network kovanGreat call. I can add that in!
Just encountered this error myself. For me, running VS code as admin solved it.
Ran in the same issue and
adding dotenv: .envtobrownie-config.yamlwill solve it. Also remember to put .env in the main folderin brownie-config.yaml add this dotenv : .env
This solved it for me too…oops!
For anyone still facing the issue after trying everything suggested in this thread: To me it happened in Lesson 10: Defi & Aave, it might sound silly, but when following close to the tutorial around 09:01:00, the script is run before you ever compiled the code. So if you have the same issue as me, try running
before running the script.
thanks for the suggestion @tobiade I managed to figure it out
Okay I’ve just realised what my problem is - the brownie-config.yaml file has to be at the root of the project e.g
@redcloud86 maybe try that?
Yes - do you want me to close it since I opened it?
Sent from my iPhone