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

Fresh windows 10 install - ErrorHook issue #3050

Closed
k2riddim opened this issue Aug 31, 2022 · 20 comments · Fixed by #3182
Closed

Fresh windows 10 install - ErrorHook issue #3050

k2riddim opened this issue Aug 31, 2022 · 20 comments · Fixed by #3182
Assignees
Labels
A-releases Area: releases/packaging T-bug Type: bug

Comments

@k2riddim
Copy link

After using rustup and the following cmd >

when trying cmd >

  • forge init hello_foundry

I get :
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
cli\src\handler.rs:62:9

@mattsse mattsse self-assigned this Aug 31, 2022
@mattsse
Copy link
Member

mattsse commented Aug 31, 2022

hmm, this is very strange because this is basically the first thing we're calling so there shouldn't be anything else that sets this.

does cast work?

that uses the same setup routine

just to be sure forge --version prints the current build time and forge is indeed .cargo/bin/forge?

@k2riddim
Copy link
Author

cast doesn't work either, exact same error msg.

Also forge --version don't work for the same reason.

And yes forge is indeed in .cargo/bin/forge

@mattsse
Copy link
Member

mattsse commented Aug 31, 2022

weird, I don't have a windows machine so I can only give you some instructions for how to debug this

could you try:

  1. clone repo
  2. cargo run --bin forge -- --version

the handler is installed here in the main

handler::install()?;

and this is where it panics

eyre::set_hook(Box::new(move |_| Box::new(Handler)))?;

Unclear to me why there would be a hook set already

@onbjerg onbjerg transferred this issue from foundry-rs/book Sep 1, 2022
@onbjerg onbjerg added T-bug Type: bug A-releases Area: releases/packaging labels Sep 1, 2022
@mattsse
Copy link
Member

mattsse commented Sep 5, 2022

any luck debugging this @k2riddim ?

@k2riddim
Copy link
Author

k2riddim commented Sep 5, 2022

hey, no sorry, I had to install wsl

@DaniPopes
Copy link
Member

DaniPopes commented Sep 6, 2022

Could reproduce, Windows 10 with a fresh VS 2022 install and using the same command as OP:

PS C:\Users\Daniel> forge -V
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
    cli\src\handler.rs:62:9
PS C:\Users\Daniel> cast -V
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
    cli\src\handler.rs:62:9
PS C:\Users\Daniel> anvil -V
anvil 0.1.0 (76be373 2022-09-06T19:36:52.9230886Z)
PS C:\Users\Daniel> rustup -V
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.63.0 (4b91a6ea7 2022-08-08)`

Although building from source works just fine:

PS C:\Users\Daniel\Documents\GitHub\foundry-rs\foundry> cargo run --bin forge -- -V
    Finished dev [unoptimized] target(s) in 0.59s
     Running `target\debug\forge.exe -V`
forge 0.2.0 (a78aa49 2022-09-06T19:54:43.4517457Z)
PS C:\Users\Daniel\Documents\GitHub\foundry-rs\foundry> cargo run --bin forge -- init ..\..\DaniPopes\HelloFoundry
    Finished dev [unoptimized] target(s) in 0.57s
     Running `target\debug\forge.exe init ..\..\DaniPopes\HelloFoundry`
Initializing C:\Users\Daniel\Documents\GitHub\DaniPopes\HelloFoundry...
Installing forge-std in "C:/Users/Daniel/Documents/GitHub/DaniPopes/HelloFoundry\\lib\\forge-std" (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
    Installed forge-std
    Initialized forge project.
PS C:\Users\Daniel\Documents\GitHub\foundry-rs\foundry> cd ..\..\DaniPopes\HelloFoundry
PS C:\Users\Daniel\Documents\GitHub\DaniPopes\HelloFoundry> ls


    Directory: C:\Users\Daniel\Documents\GitHub\DaniPopes\HelloFoundry


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        06/09/2022     21:58                .github
d-----        06/09/2022     21:58                lib
d-----        06/09/2022     21:58                script
d-----        06/09/2022     21:58                src
d-----        06/09/2022     21:58                test
-a----        06/09/2022     21:58            143 .gitignore
-a----        06/09/2022     21:58             97 .gitmodules
-a----        06/09/2022     21:58            140 foundry.toml


PS C:\Users\Daniel\Documents\GitHub\DaniPopes\HelloFoundry> forge test
[⠊] Compiling...
[⠘] installing solc version "0.8.16"
[⠆] Successfully installed solc 0.8.16
[⠊] Compiling 10 files with 0.8.16
[⠢] Solc 0.8.16 finished in 1.70s
Compiler run successful

Running 2 tests for test/Counter.t.sol:CounterTest
[PASS] testIncrement() (gas: 28312)
[PASS] testSetNumber(uint256) (runs: 256, μ: 27454, ~: 28387)
Test result: ok. 2 passed; 0 failed; finished in 9.35ms

@mattsse
Copy link
Member

mattsse commented Sep 6, 2022

this doesn't make any sense...

@DaniPopes
Copy link
Member

DaniPopes commented Sep 6, 2022

Same command as OP but using local Foundry repo works:

PS C:\Users\Daniel\Documents\GitHub\foundry-rs\foundry> cargo install --path .\cli\ foundry-cli --bins --locked
[...]
    Replaced package `foundry-cli v0.2.0 (https://github.com/foundry-rs/foundry#76be373d)` with `foundry-cli v0.2.0 (C:\Users\Daniel\Documents\GitHub\foundry-rs\foundry\cli)` (executables `cast.exe`, `forge.exe`)
PS C:\Users\Daniel\Documents\GitHub\foundry-rs\foundry> forge -V
forge 0.2.0 (a78aa49 2022-09-06T20:12:12.3499251Z)

No clue what's going on lol

Edit: initial command now works. Removed ~/.cargo/{git,registry}, re ran and also works. Don't know what to make of this, I guess just try running the command twice or clone the repo and install from there

@Elyx0
Copy link

Elyx0 commented Sep 7, 2022

What could be added to docs is rustup update for windows that fixed it for me (was having bluealloy/revm#170 )

@mattsse
Copy link
Member

mattsse commented Sep 7, 2022

hmm perhaps this is an issue with older rust versions, but still doesn't make much sense, since there's no call before

eyre::set_hook(Box::new(move |_| Box::new(Handler)))?;

that sets this...

@juanfranblanco
Copy link

I have replicated this, and I am still having the same issues, tried using different versions of Rust beta and nightly. Also installed from github and using OP commands. Workaround is to use WSL or MINGW64, but not ideal.

@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

this is so weird to me ...

I guess we could make this not a hard error in windows as a workaround

@mattsse
Copy link
Member

mattsse commented Sep 12, 2022

perhaps this is related rust-lang/rust#81408

@juanfranblanco
Copy link

@mattsse i removed the hook locally and is all good, so your fix does the trick

@xphoniex
Copy link
Contributor

xphoniex commented Dec 14, 2022

I ran into the same issue but instead of a fresh windows 10 os, I'm running linux.

You should be able to reproduce it using a VM or something. Compile from 67ef930 and move binaries to the new VM:

$ cast
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
cli/src/handler.rs:70:13

This happens in cast & forge, but not in anvil.

@xphoniex
Copy link
Contributor

I tried by setting FOUNDRY_DEBUG still no luck:

$ FOUNDRY_DEBUG= ./cast -V
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
    /home/user/.cargo/registry/src/git.luolix.top-.../color-eyre-0.6.1/src/config.rs:686.9

it also ends up calling eyre_hook.install()?, any idea how to fix this @mattsse ?

@karmacoma-eth
Copy link
Contributor

Do you think this could be the issue described in this comment @mattsse?

eyre-rs/eyre#90 (comment)

@leovct
Copy link
Contributor

leovct commented Jun 20, 2023

Same thing happened to me using a debian container: anvil works fine but not forge and cast.
The solution was simply to install git.

FROM debian:bullseye-slim as foundry-install
RUN apt-get update -y && apt-get install -y curl git unzip wget
RUN curl -L https://foundry.paradigm.xyz | bash
RUN /root/.foundry/bin/foundryup
RUN cp -r /root/.foundry/bin/* /usr/local/bin

FROM debian:bookworm-slim
# RUN apt-get update -y && apt-get install -y git # solution
COPY --from=foundry-install /usr/local/bin /usr/local/bin
$ root@status:/# forge --version
bash: forge: command not found

$ root@status:/# cast --version
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
    cli/src/handler.rs:70:13

$ anvil
# works as expected

@llllvvuu
Copy link
Contributor

llllvvuu commented Jul 6, 2023

Same thing happened to me using a debian container: anvil works fine but not forge and cast. The solution was simply to install git.

FROM debian:bullseye-slim as foundry-install
RUN apt-get update -y && apt-get install -y curl git unzip wget
RUN curl -L https://foundry.paradigm.xyz | bash
RUN /root/.foundry/bin/foundryup
RUN cp -r /root/.foundry/bin/* /usr/local/bin

FROM debian:bookworm-slim
# RUN apt-get update -y && apt-get install -y git # solution
COPY --from=foundry-install /usr/local/bin /usr/local/bin
$ root@status:/# forge --version
bash: forge: command not found

$ root@status:/# cast --version
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
    cli/src/handler.rs:70:13

$ anvil
# works as expected

Thanks, this works on Alpine too. Strange error message but it makes sense since I guess git is used to search for the foundry.toml

@pipaman
Copy link

pipaman commented Oct 19, 2023

This issue is not letting me use the tool in an airgapped computer. It is a pity since the tool is really good. I downloaded Nightly (2023-10-19) and got:
Error: cannot install provided ErrorHook, a hook has already been installed

Location:
cli/src/handler.rs:70:13

OS: Ubuntu 22.04.03 LTS out of the bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-releases Area: releases/packaging T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.