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

Avoid duplicate crates #832

Closed
wants to merge 1 commit into from
Closed

Avoid duplicate crates #832

wants to merge 1 commit into from

Conversation

rex4539
Copy link
Contributor

@rex4539 rex4539 commented Feb 24, 2025

No description provided.

@yorickpeterse
Copy link
Collaborator

@rex4539 What is the goal of these changes? There is zero information in the commit message or pull request description, and I can't tell from these changes if there's an actual benefit to them.

@rex4539
Copy link
Contributor Author

rex4539 commented Feb 24, 2025

When you have multiple packages in a Cargo workspace, you often end up depending on the same packages in multiple Cargo.toml files.

This duplication can become an issue:
When you want to update a dependency, you have to update it in multiple places.
When you need to add a new dependency, you first have to check if it's already used in another package of your workspace to keep versions in sync.

This process it's error-prone and tedious.

If you mess it up, you end up with different versions of the same dependency within your workspace. This can lead to hard-to-debug compilation errors or bloat your artifacts with unnecessary copies of the same package.

@yorickpeterse
Copy link
Collaborator

@rex4539 While there are some overlapping packages in between the crates, most of them have unique dependencies, so moving them to the workspace level won't help much.

As far as duplicate crates go, this isn't much of an issue either per cargo tree:

ast v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/ast)
├── location v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/location)
└── unicode-segmentation v1.12.0
[dev-dependencies]
└── similar-asserts v1.6.1
    ├── console v0.15.10
    │   ├── libc v0.2.169
    │   └── once_cell v1.20.3
    └── similar v2.7.0
        └── unicode-segmentation v1.12.0

compiler v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/compiler)
├── ast v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/ast) (*)
├── blake3 v1.5.5
│   ├── arrayref v0.3.9
│   ├── arrayvec v0.7.6
│   ├── cfg-if v1.0.0
│   └── constant_time_eq v0.3.1
│   [build-dependencies]
│   └── cc v1.2.14
│       └── shlex v1.3.0
├── crossbeam-queue v0.3.12
│   └── crossbeam-utils v0.8.21
├── fnv v1.0.7
├── indexmap v2.7.1
│   ├── equivalent v1.0.2
│   └── hashbrown v0.15.2
├── inkwell v0.5.0
│   ├── either v1.13.0
│   ├── inkwell_internals v0.10.0 (proc-macro)
│   │   ├── proc-macro2 v1.0.93
│   │   │   └── unicode-ident v1.0.16
│   │   ├── quote v1.0.38
│   │   │   └── proc-macro2 v1.0.93 (*)
│   │   └── syn v2.0.98
│   │       ├── proc-macro2 v1.0.93 (*)
│   │       ├── quote v1.0.38 (*)
│   │       └── unicode-ident v1.0.16
│   ├── libc v0.2.169
│   ├── llvm-sys v170.2.0
│   │   └── libc v0.2.169
│   │   [build-dependencies]
│   │   ├── anyhow v1.0.95
│   │   ├── cc v1.2.14 (*)
│   │   ├── lazy_static v1.5.0
│   │   ├── regex-lite v0.1.6
│   │   └── semver v1.0.25
│   ├── once_cell v1.20.3
│   └── thiserror v1.0.69
│       └── thiserror-impl v1.0.69 (proc-macro)
│           ├── proc-macro2 v1.0.93 (*)
│           ├── quote v1.0.38 (*)
│           └── syn v2.0.98 (*)
├── llvm-sys v170.2.0 (*)
├── location v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/location)
├── types v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/types)
│   ├── indexmap v2.7.1 (*)
│   └── location v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/location)
└── unicode-width v0.2.0
[dev-dependencies]
└── similar-asserts v1.6.1 (*)

inko v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/inko)
├── blake3 v1.5.5 (*)
├── compiler v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/compiler) (*)
├── flate2 v1.0.35
│   ├── crc32fast v1.4.2
│   │   └── cfg-if v1.0.0
│   └── miniz_oxide v0.8.4
│       └── adler2 v2.0.0
├── getopts v0.2.21
│   └── unicode-width v0.1.14
├── tar v0.4.43
│   ├── filetime v0.2.25
│   │   ├── cfg-if v1.0.0
│   │   └── libc v0.2.169
│   └── libc v0.2.169
├── types v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/types) (*)
└── ureq v3.0.5
    ├── base64 v0.22.1
    ├── flate2 v1.0.35 (*)
    ├── log v0.4.25
    ├── percent-encoding v2.3.1
    ├── rustls v0.23.23
    │   ├── log v0.4.25
    │   ├── once_cell v1.20.3
    │   ├── ring v0.17.9
    │   │   ├── cfg-if v1.0.0
    │   │   ├── getrandom v0.2.15
    │   │   │   ├── cfg-if v1.0.0
    │   │   │   └── libc v0.2.169
    │   │   └── untrusted v0.9.0
    │   │   [build-dependencies]
    │   │   └── cc v1.2.14 (*)
    │   ├── rustls-pki-types v1.11.0
    │   ├── rustls-webpki v0.102.8
    │   │   ├── ring v0.17.9 (*)
    │   │   ├── rustls-pki-types v1.11.0
    │   │   └── untrusted v0.9.0
    │   ├── subtle v2.6.1
    │   └── zeroize v1.8.1
    ├── rustls-pemfile v2.2.0
    │   └── rustls-pki-types v1.11.0
    ├── rustls-pki-types v1.11.0
    ├── ureq-proto v0.3.0
    │   ├── base64 v0.22.1
    │   ├── http v1.2.0
    │   │   ├── bytes v1.10.0
    │   │   ├── fnv v1.0.7
    │   │   └── itoa v1.0.14
    │   ├── httparse v1.10.0
    │   └── log v0.4.25
    ├── utf-8 v0.7.6
    └── webpki-roots v0.26.8
        └── rustls-pki-types v1.11.0

location v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/location)

rt v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/rt)
├── backtrace v0.3.74
│   ├── addr2line v0.24.2
│   │   └── gimli v0.31.1
│   ├── cfg-if v1.0.0
│   ├── libc v0.2.169
│   ├── miniz_oxide v0.8.4 (*)
│   ├── object v0.36.7
│   │   └── memchr v2.7.4
│   └── rustc-demangle v0.1.24
├── crossbeam-queue v0.3.12 (*)
├── crossbeam-utils v0.8.21
├── libc v0.2.169
├── once_cell v1.20.3
├── rand v0.8.5
│   ├── libc v0.2.169
│   ├── rand_chacha v0.3.1
│   │   ├── ppv-lite86 v0.2.20
│   │   │   └── zerocopy v0.7.35
│   │   │       ├── byteorder v1.5.0
│   │   │       └── zerocopy-derive v0.7.35 (proc-macro)
│   │   │           ├── proc-macro2 v1.0.93 (*)
│   │   │           ├── quote v1.0.38 (*)
│   │   │           └── syn v2.0.98 (*)
│   │   └── rand_core v0.6.4
│   │       └── getrandom v0.2.15 (*)
│   └── rand_core v0.6.4 (*)
├── rustix v0.38.44
│   ├── bitflags v2.8.0
│   └── linux-raw-sys v0.4.15
├── rustls v0.23.23 (*)
├── rustls-native-certs v0.7.3
│   ├── openssl-probe v0.1.6
│   ├── rustls-pemfile v2.2.0 (*)
│   └── rustls-pki-types v1.11.0
├── rustls-pemfile v2.2.0 (*)
├── rustls-webpki v0.102.8 (*)
└── unicode-segmentation v1.12.0

types v0.18.1 (/var/home/yorickpeterse/Projects/inko/inko/types) (*)

unicode-width is present twice, but this will be resolved as part of #813 which I'm actively working on. For any remaining duplicates the general idea is the same: try and remove the dependencies entirely, instead of deduping them.

Maintenance wise I actually prefer to keep dependencies isolated to their crates, as the workspace approach actually seems to introduce duplicate work: you have to specify a dependency entry at the crate level and the workspace level, instead of only at the crate level.

Based on this, we won't adopt this workspace dependency approach. For future contributions, please create an issue first and discuss the proposal there (see also our contributing guidelines). This way you can avoid spending time on work that will be rejected anyway.

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