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

Integration with hardhat does not work on windows #1482

Open
Minh-Trng opened this issue Mar 24, 2022 · 1 comment
Open

Integration with hardhat does not work on windows #1482

Minh-Trng opened this issue Mar 24, 2022 · 1 comment

Comments

@Minh-Trng
Copy link
Contributor

Environment information

  • brownie Version: 1.18.1
  • ganache-cli Version: 7.0.2
  • solc Version: 1.1.1
  • Python Version: 3.9.5
  • OS: win

What was wrong?

I tried to replace ganache with hardhat in order to be able to use the console.log functionality within smart contracts. After failing to integrate it in an existing project I made a new project with a new venv and only ran the following commands mentioned in the docs to get it up and running:

  1. pip install eth-brownie
  2. npm install --save-dev hardhat
  3. brownie console --network hardhat

Same as in the existing project the last command failed with the following error output:

Launching 'npx hardhat node --port 8545'...
File "c:\users\minht\documents\pythonprojects\hardhatwithbrownie\venv\lib\site-packages\brownie_cli_main
.py", line 64, in main
importlib.import_module(f"brownie.cli.{cmd}").main()
File "c:\users\minht\documents\pythonprojects\hardhatwithbrownie\venv\lib\site-packages\brownie_cli\console.py", line 58, in main
network.connect(CONFIG.argv["network"])
File "c:\users\minht\documents\pythonprojects\hardhatwithbrownie\venv\lib\site-packages\brownie\network\main.py", line 50, in connect
rpc.launch(active["cmd"], **active["cmd_settings"])
File "c:\users\minht\documents\pythonprojects\hardhatwithbrownie\venv\lib\site-packages\brownie\network\rpc_init
.py", line 75, in launch
self.process = self.backend.launch(cmd, **kwargs)
File "c:\users\minht\documents\pythonprojects\hardhatwithbrownie\venv\lib\site-packages\brownie\network\rpc\hardhat.py", line 74, in launch
return psutil.Popen(cmd_list, stdin=DEVNULL, stdout=out, stderr=out)
File "c:\users\minht\documents\pythonprojects\hardhatwithbrownie\venv\lib\site-packages\psutil_init_.py", line 1319, in init
self.__subproc = subprocess.Popen(*args, **kwargs)
File "C:\Users\minht\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\minht\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

@Minh-Trng
Copy link
Contributor Author

found the problem: in hardhat.py the following lines were commented out:

def launch(cmd: str, **kwargs: Dict) -> None:
    """Launches the RPC client.
    Args:
        cmd: command string to execute as subprocess"""
    # if sys.platform == "win32" and not cmd.split(" ")[0].endswith(".cmd"):
    #     if " " in cmd:
    #         cmd = cmd.replace(" ", ".cmd ", 1)
    #     else:
    #         cmd += ".cmd"

those are necessary to turn "npx hardhat node ..." into "npx.cmd hardhat node ..." which the winapi is able to resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant