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

Environment variable, ETH_RPC_URL, is not being picked up by forge script #7755

Closed
2 tasks done
ShaneDuncan602 opened this issue Apr 22, 2024 · 4 comments
Closed
2 tasks done
Labels
A-config Area: config Cmd-forge-script Command: forge script T-bug Type: bug

Comments

@ShaneDuncan602
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (63fff35 2024-04-22T00:25:29.889454000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

In previous versions of forge, ETH_RPC_URL could be set in the terminal via export and forge script would pick it up. When it was not set at all, it would default to the local anvil instance. These no longer happen. rpc-url has to be explicitly on the command now, even for local anvil instance at 127.0.0.1:8545.

@ShaneDuncan602 ShaneDuncan602 added the T-bug Type: bug label Apr 22, 2024
@klkvr
Copy link
Member

klkvr commented Apr 22, 2024

--rpc-url in cast commands is coming from RpcOpts:

#[arg(short = 'r', long = "rpc-url", env = "ETH_RPC_URL")]
pub url: Option<String>,

and for forge we are using EvmArgs::fork_url:

#[arg(long, short, visible_alias = "rpc-url", value_name = "URL")]
#[serde(rename = "eth_rpc_url", skip_serializing_if = "Option::is_none")]
pub fork_url: Option<String>,

the latter does not have a env = "ETH_RPC_URL" and I don't think it had it at some point before

I don't think we should enable this now as this would cause people's forge test commands to run in forked environment if they have a ETH_RPC_URL variable set which will slow down tests a lot

cc @mattsse @DaniPopes @zerosnacks

@mattsse
Copy link
Member

mattsse commented Apr 22, 2024

if they have a ETH_RPC_URL variable set which will slow down tests a lot

yeah, if --fork-url is provided all test launch in forking mode
this can cause issues if the same var is used as smth like mainnet = ${ETH_RPC_URL} in foundry.toml.

@jjbailey-io
Copy link

jjbailey-io commented Apr 23, 2024

Can you help us understand why the previous versions of foundry handled this case differently? In the past we did not have to specify this in every command because it automatically picked up on the environment variable. Did the most recent version change how it handles environment variables or specifically this argument? The puzzling behavior is the need to specify it for a local anvil instance now.

@zerosnacks zerosnacks added Cmd-forge-script Command: forge script A-config Area: config labels Jun 27, 2024
@zerosnacks
Copy link
Member

Marking as not planned per the comments

@jjbailey-io because of how environment variables overrule any configuration you can easily get into a situation like every test being ran as a fork test, this has significant overhead. There is a meta-ticket here: #7322 tracking proposed improvements around prioritisation in the CLI

@zerosnacks zerosnacks closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-config Area: config Cmd-forge-script Command: forge script T-bug Type: bug
Projects
None yet
Development

No branches or pull requests

5 participants