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

Certain feature combination does not compile #137

Open
dthul opened this issue Jan 11, 2022 · 10 comments · Fixed by #452
Open

Certain feature combination does not compile #137

dthul opened this issue Jan 11, 2022 · 10 comments · Fixed by #452
Labels
bug Something isn't working
Milestone

Comments

@dthul
Copy link

dthul commented Jan 11, 2022

I'm using the following line in my Cargo.toml:

async-stripe = { version = "0.13", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events"] }

and this is the compile error I get:

   Compiling async-stripe v0.13.0
error[E0432]: unresolved import `crate::resources::CheckoutSessionItem`
  --> /home/dthul/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/async-stripe-0.13.0/src/resources/generated/quote.rs:11:14
   |
11 |     Account, CheckoutSessionItem, Currency, Customer, Discount, Invoice,
   |              ^^^^^^^^^^^^^^^^^^^
   |              |
   |              no `CheckoutSessionItem` in `resources`
   |              help: a similar name exists in the module: `CheckoutSession`

As far as I can tell CheckoutSessionItem will only be re-exported from crate::resources when the checkout Cargo feature is activated.
As a quick fix I changed my dependency line to:

async-stripe = { version = "0.13", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events", "checkout"] }
@arlyon
Copy link
Owner

arlyon commented Jan 12, 2022

Thanks for the report. I'll have a look and see if we can either a) rework the deps or b) at least document this requirement.

@arlyon arlyon added the bug Something isn't working label Mar 1, 2022
@arlyon
Copy link
Owner

arlyon commented Mar 22, 2022

We are planning on addressing this issue with 0.15 where we will split out the codegen into crates. This will make the dependencies much more explicit. Stay tuned.

@arlyon arlyon added this to the 0.15.0 milestone Mar 25, 2022
@fancywriter
Copy link

Hi @arlyon
I am experiencing similar issue as @dthul .

And also trying to undestand which feature I have to enable to make use stripe::TerminalLocation; to compile, it complains

6 | use stripe::TerminalLocation;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ no `TerminalLocation` in the root

I have noticed that this code is generated https://github.com/arlyon/async-stripe/blob/ca5269ebcf9cbd7005f3fecedc63cc31718680a6/src/resources/generated/terminal_location.rs

Tried to add "terminal" or "terminal-location" features, but none of them worked:

the package `my_example` depends on `async-stripe`, with features: `terminal-location` but `async-stripe` does not have these features.

@arlyon
Copy link
Owner

arlyon commented May 4, 2022

Hi

The terminal APIs are currently not exported (and untested). I will write a PR to add them and you can provide feedback. Everything should 'just work' after that.

See here for a list of unexported APIs (updated weekly with): #216

I am adding terminal support in this PR: #221

@arlyon
Copy link
Owner

arlyon commented May 4, 2022

The pr is merged let me know if there are any issues with the terminal API.

@dthul
Copy link
Author

dthul commented Jun 10, 2022

When I updated to v0.15 I ran into a new but similar compile issue. The Cargo.toml line I used:

async-stripe = { version = "0.15", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events", "checkout"] }

which leads to this error:

    Checking async-stripe v0.15.0
error[E0412]: cannot find type `AccountCapabilities` in this scope
   --> /home/dthul/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/async-stripe-0.15.0/src/resources/webhook_events.rs:444:25
    |
444 |     AccountCapabilities(AccountCapabilities),
    |                         ^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::AccountCapabilities`; try using the variant's enum
    |
444 |     AccountCapabilities(crate::EventObject),
    |                         ~~~~~~~~~~~~~~~~~~

and the new line which makes it work (by adding the "connect" feature which will re-export the AccountCapabilities struct):

async-stripe = { version = "0.15", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events", "checkout", "connect"] }

@cortopy
Copy link

cortopy commented Jun 11, 2022

I also bumped into this. I only need the webhook-events feature in addition to runtime.

In my case this works

async-stripe = { version = "0.15.0", default-features = false, features = ["runtime-tokio-hyper", "webhook-events", "connect", "checkout"]}

It seems like webhook-events should also activate connect and checkout

@mzeitlin11
Copy link
Collaborator

Copying from #238: after updating to 0.15.0, a set of features that built fine in 0.14.1 now doesn't compile. A minimal Cargo.toml which compiles for 0.14 but not 0.15.0:

[dependencies]
async-stripe = {version = "0.15.0", default-features = false, features = ["runtime-tokio-hyper", "webhook-events", "checkout"]}

The compilation error:

error[E0412]: cannot find type `AccountCapabilities` in this scope
   --> /Users/matthewzeitlin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/async-stripe-0.15.0/src/resources/webhook_events.rs:444:25
    |
444 |     AccountCapabilities(AccountCapabilities),
    |                         ^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::AccountCapabilities`; try using the variant's enum
    |
444 |     AccountCapabilities(crate::EventObject),
    |                         ~~~~~~~~~~~~~~~~~~

Adding the feature connect fixes this compilation error.

@lgarron
Copy link

lgarron commented Mar 20, 2024

I ran into this today with:

# Cargo.toml
async-stripe = { version = "0.34.1", default-features = false, features = ["runtime-blocking-rustls", "billing"] }
use stripe::{ListSubscriptions, StripeError, Subscription};
const TEST_SECRET_KEY: &str = "sk_test_…";

use stripe::{ListSubscriptions, StripeError, Subscription};

async fn test() -> Result<(), StripeError> {
    let client = stripe::Client::new(TEST_SECRET_KEY);
    let s = Subscription::list(&client, &ListSubscriptions::default())?;
    dbg!(s);
    Ok(())
}

This results in:

error[E0432]: unresolved import `crate::resources::CheckoutSessionItem`
  --> /…/.cache/cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/generated/quote.rs:11:27
   |
11 |     Account, Application, CheckoutSessionItem, ConnectAccountReference, Currency, Customer,
   |                           ^^^^^^^^^^^^^^^^^^^
   |                           |
   |                           no `CheckoutSessionItem` in `resources`
   |                           help: a similar name exists in the module: `CheckoutSession`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `async-stripe` (lib) due to 1 previous error

@thomasmost
Copy link
Contributor

#634 is essentially a dupe of this issue. Seems like the common experience is that structs aren't available to webhook handlers without the API feature they belong to. the Structs themselves should probably be available always, or in separate 'model-only' crates that the "webhook-events" feature depends on (as well as their API features)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants