question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Unable to expand environment variable in host setting

See original GitHub issue

Environment information

  • eth-brownie>=1.10.0,<2.0.0
  • ganache-cli Version: 6.12.2
  • solc Version: 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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:53 (13 by maintainers)

github_iconTop GitHub Comments

25reactions
MelbyBaldovecommented, Oct 10, 2021

So I ran into this issue while I was doing test_lottery_unit.py of @PatrickAlphaC 's tutorial.

This might help you guys. Add this to the script

from dotenv import load_dotenv

load_dotenv()
21reactions
xAslancommented, Nov 20, 2021

I also ran into this issue running brownie test -k test_get_entrance_fee --network rinkeby

solved by adding dotenv: .env to brownie-config.yaml

Read more comments on GitHub >

github_iconTop Results From Across the Web

eth-brownie: Unable to expand environment variable in host ...
You can fix it by setting the variable in your .env file and adding dotenv: .env to your brownie-config.yaml . ... Remember to...
Read more >
Brownie / Rinkeby: Unable to expand environment variable in ...
You can fix it by setting the variable in your .env file and adding dotenv: .env to your brownie-config.yaml . brownie-config.yaml :
Read more >
Help With Brownie and Infura Environment Variables (Will ...
I think my problem is with the environment variables in brownie(I'm ... ValueError: Unable to expand environment variable in host setting: ...
Read more >
eth-brownie/community - Gitter
You can specify the location of the build folder in the config file. ... Unable to expand environment variable in host setting: ...
Read more >
Problems with Environment Variables
If the error message states that the environment variable is not set, IT MEANS PRECISELY THAT ! The most likely reason is that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found