Skip to content

Conversation

l-monninger
Copy link
Contributor

@l-monninger l-monninger commented Jun 12, 2025

Summary

Uses cargo-machete to check for unused dependencies in the pre-commit hook. Errors the pre-commit if there are unused or unpatched dependencies.

I also naturally removed dependencies which would currently violate this check.

Tip

To double check the erroring on unused dependencies, add some like future = { workspace = true } to a crate and try to commit it.

Note

I checked this out from #152 because I wanted to clean as many dependencies as possible.

@l-monninger l-monninger changed the base branch from main to l-monninger/environments-api June 12, 2025 13:42
@andygolay
Copy link
Collaborator

@l-monninger I noticed cargo check --all-targets failed due to some missing deps so I pushed a commit to fix it.

Copy link
Collaborator

@andygolay andygolay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but the cargo test check I keep getting

error: Cannot build '/nix/store/fdyrnfa2an9l6jqmlj40yh8ln4sx5vaj-celestia-node-0.20.4-go-modules.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/fp33wa4rk3j4rs2s64bf7n3ni0lk73bj-celestia-node-0.20.4-go-modules
       Last 25 log lines:
       > go: github.com/celestiaorg/celestia-node/cmd imports
       >     github.com/celestiaorg/celestia-app/v3/app imports
       >      github.com/cosmos/ibc-go/v6/testing imports
       >     github.com/cosmos/ibc-go/v6/testing/simapp imports
       >      github.com/cosmos/cosmos-sdk/x/upgrade: github.com/celestiaorg/[email protected]: reading https://proxy.golang.org/github.com/celestiaorg/cosmos-sdk/@v/v1.25.0-sdk-v0.46.16.zip: 500 Internal Server Error
       > go: github.com/celestiaorg/celestia-node/cmd imports
       >  github.com/celestiaorg/celestia-app/v3/app imports
       >      github.com/cosmos/ibc-go/v6/testing imports
       >     github.com/cosmos/ibc-go/v6/testing/simapp imports
       >      github.com/cosmos/cosmos-sdk/x/upgrade/client: github.com/celestiaorg/[email protected]: reading https://proxy.golang.org/github.com/celestiaorg/cosmos-sdk/@v/v1.25.0-sdk-v0.46.16.zip: 500 Internal Server Error
       > go: github.com/celestiaorg/celestia-node/cmd/cel-shed imports
       >  github.com/grafana/pyroscope-go imports
       >         github.com/grafana/pyroscope-go/godeltaprof imports
       >     github.com/grafana/pyroscope-go/godeltaprof/internal/pprof imports
       >      github.com/klauspost/compress/gzip: github.com/klauspost/[email protected]: reading https://proxy.golang.org/github.com/klauspost/compress/@v/v1.17.11.zip: 503 Service Unavailable
       > go: github.com/celestiaorg/celestia-node/nodebuilder imports
       >        github.com/ipfs/go-ds-badger4 imports
       >   github.com/dgraph-io/badger/v4 imports
       >  github.com/dgraph-io/badger/v4/table imports
       >    github.com/klauspost/compress/s2: github.com/klauspost/[email protected]: reading https://proxy.golang.org/github.com/klauspost/compress/@v/v1.17.11.zip: 503 Service Unavailable
       > go: github.com/celestiaorg/celestia-node/nodebuilder imports
       >  github.com/ipfs/go-ds-badger4 imports
       >   github.com/dgraph-io/badger/v4 imports
       >  github.com/dgraph-io/badger/v4/table imports
       >    github.com/klauspost/compress/snappy: github.com/klauspost/[email protected]: reading https://proxy.golang.org/github.com/klauspost/compress/@v/v1.17.11.zip: 503 Service Unavailable
       For full logs, run:
         nix log /nix/store/fdyrnfa2an9l6jqmlj40yh8ln4sx5vaj-celestia-node-0.20.4-go-modules.drv
error: Cannot build '/nix/store/a73n8cylx33l041f0axbrjxs8ir8mr59-celestia-node-0.20.4.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/ikkxf61kmpvw2li0f00yvkhyp1m4d2z3-celestia-node-0.20.4
error: Cannot build '/nix/store/l3k7yvi718v6qq7aqsb11jqm8pm4d1js-nix-shell-env.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/yzjd1hyzr7b0jv28sxgjpc8djrrjqcdx-nix-shell-env

I've retried it a couple times now.

Copy link
Collaborator

@andygolay andygolay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is now green after a few tries.

I attempted to add an import into a module without adding to Cargo.toml:
image
and an unused dep in Cargo.toml:
image
:shipit:

@andygolay andygolay merged commit 5599c72 into l-monninger/environments-api Jun 12, 2025
14 of 16 checks passed
@l-monninger
Copy link
Contributor Author

l-monninger commented Jun 13, 2025

Yeah, I saw the email @andygolay. Something to be aware of. It might be nice to pair this with a cargo check --all-targets in the pre-commit hook to produce a feedback loop of sorts.

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

Successfully merging this pull request may close these issues.

2 participants