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

Remove binary-specific dependencies from bat library #895

Closed
dtolnay opened this issue Mar 29, 2020 · 1 comment · Fixed by #899
Closed

Remove binary-specific dependencies from bat library #895

dtolnay opened this issue Mar 29, 2020 · 1 comment · Fixed by #899
Labels
bat-as-a-library Related to bat-as-a-library feature-request New feature or request help wanted Extra attention is needed

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Mar 29, 2020

I am considering using bat-as-a-library in https://github.com/dtolnay/cargo-expand but I found that the library pulls in an enormous dependency tree, a lot of which appears to be specific to the bat command line tool. For example liquid seems to be related to the bat.1 manpage and fish completions, neither of which should be needed for library mode. clap also doesn't seem like it should be necessary in library mode.

I pasted the liquid dependency graph below. This by itself is big enough that it really makes me hesitant about adding a library dependency on bat especially when liquid won't even be used at all by the library.

Could you consider adding an on-by-default feature for pulling in the binary-specific dependencies, so that crates that depend on bat as a library can opt out of them? Or alternatively, consider moving the bat library to a different crate name so it doesn't need to share a Cargo.toml with the binary?

    └── liquid v0.19.0
        ├── chrono v0.4.11
        │   ├── num-integer v0.1.42
        │   │   └── num-traits v0.2.11
        │   │       [build-dependencies]
        │   │       └── autocfg v1.0.0
        │   │   [build-dependencies]
        │   │   └── autocfg v1.0.0 (*)
        │   ├── num-traits v0.2.11 (*)
        │   └── time v0.1.42
        │       └── libc v0.2.68 (*)
        ├── deunicode v1.1.0
        ├── doc-comment v0.3.3
        ├── itertools v0.8.2
        │   └── either v1.5.3
        ├── lazy_static v1.4.0 (*)
        ├── liquid-compiler v0.19.0
        │   ├── itertools v0.8.2 (*)
        │   ├── liquid-error v0.19.0
        │   ├── liquid-interpreter v0.19.0
        │   │   ├── anymap v0.12.1
        │   │   ├── itertools v0.8.2 (*)
        │   │   ├── liquid-error v0.19.0 (*)
        │   │   └── liquid-value v0.19.1
        │   │       ├── chrono v0.4.11 (*)
        │   │       ├── itertools v0.8.2 (*)
        │   │       ├── liquid-error v0.19.0 (*)
        │   │       ├── num-traits v0.2.11 (*)
        │   │       └── serde v1.0.105 (*)
        │   ├── liquid-value v0.19.1 (*)
        │   ├── pest v2.1.3
        │   │   └── ucd-trie v0.1.3
        │   └── pest_derive v2.1.0
        │       ├── pest v2.1.3 (*)
        │       └── pest_generator v2.1.3
        │           ├── pest v2.1.3 (*)
        │           ├── pest_meta v2.1.3
        │           │   ├── maplit v1.0.2
        │           │   └── pest v2.1.3 (*)
        │           │   [build-dependencies]
        │           │   └── sha-1 v0.8.2
        │           │       ├── block-buffer v0.7.3
        │           │       │   ├── block-padding v0.1.5
        │           │       │   │   └── byte-tools v0.3.1
        │           │       │   ├── byte-tools v0.3.1 (*)
        │           │       │   ├── byteorder v1.3.4 (*)
        │           │       │   └── generic-array v0.12.3
        │           │       │       └── typenum v1.11.2
        │           │       ├── digest v0.8.1
        │           │       │   └── generic-array v0.12.3 (*)
        │           │       ├── fake-simd v0.1.2
        │           │       └── opaque-debug v0.2.3
        │           ├── proc-macro2 v1.0.9 (*)
        │           ├── quote v1.0.3 (*)
        │           └── syn v1.0.17 (*)
        ├── liquid-derive v0.19.0
        │   ├── liquid-compiler v0.19.0 (*)
        │   ├── liquid-error v0.19.0 (*)
        │   ├── liquid-interpreter v0.19.0 (*)
        │   ├── liquid-value v0.19.1 (*)
        │   ├── proc-macro2 v0.4.30 (*)
        │   ├── proc-quote v0.2.2
        │   │   ├── proc-macro-hack v0.5.14
        │   │   ├── proc-macro2 v0.4.30 (*)
        │   │   ├── proc-quote-impl v0.2.2
        │   │   │   ├── proc-macro-hack v0.5.14 (*)
        │   │   │   ├── proc-macro2 v0.4.30 (*)
        │   │   │   └── quote v0.6.13 (*)
        │   │   ├── quote v0.6.13 (*)
        │   │   └── syn v0.15.44
        │   │       ├── proc-macro2 v0.4.30 (*)
        │   │       ├── quote v0.6.13 (*)
        │   │       └── unicode-xid v0.1.0 (*)
        │   └── syn v0.15.44 (*)
        ├── liquid-error v0.19.0 (*)
        ├── liquid-interpreter v0.19.0 (*)
        ├── liquid-value v0.19.1 (*)
        ├── regex v1.3.6 (*)
        ├── serde v1.0.105 (*)
        ├── unicode-segmentation v1.6.0
        └── url v1.7.2
            ├── idna v0.1.5
            │   ├── matches v0.1.8 (*)
            │   ├── unicode-bidi v0.3.4 (*)
            │   └── unicode-normalization v0.1.12 (*)
            ├── matches v0.1.8 (*)
            └── percent-encoding v1.0.1
@dtolnay dtolnay added the bug Something isn't working label Mar 29, 2020
@sharkdp
Copy link
Owner

sharkdp commented Mar 30, 2020

Thank you for the feedback!

Could you consider adding an on-by-default feature for pulling in the binary-specific dependencies, so that crates that depend on bat as a library can opt out of them?

I didn't really know how to fix that problem (and I don't really want to move the library to a different crate for now), but that seems like a viable option!

I pasted the liquid dependency graph below.

ouch 😄. Note that it is a build-only dependency, though. But I completely agree. Users of the library shouldn't be forced to pull in these dependencies.

@sharkdp sharkdp added bat-as-a-library Related to bat-as-a-library feature-request New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bat-as-a-library Related to bat-as-a-library feature-request New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants