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

Compilation error when compiling example.rs #633

Closed
samueldotj opened this issue May 30, 2022 · 1 comment
Closed

Compilation error when compiling example.rs #633

samueldotj opened this issue May 30, 2022 · 1 comment

Comments

@samueldotj
Copy link

I am getting the following error when compiling example.rs

error: cannot find attribute `rustyline` in this scope
  --> src/main.rs:15:7
   |
15 |     #[rustyline(Completer)]
   |       ^^^^^^^^^
   |
   = note: `rustyline` is in scope, but it is a crate, not an attribute

error: cannot find attribute `rustyline` in this scope
  --> src/main.rs:18:7
   |
18 |     #[rustyline(Validator)]
   |       ^^^^^^^^^
   |
   = note: `rustyline` is in scope, but it is a crate, not an attribute

error: cannot find attribute `rustyline` in this scope
  --> src/main.rs:20:7
   |
20 |     #[rustyline(Hinter)]
   |       ^^^^^^^^^
   |
   = note: `rustyline` is in scope, but it is a crate, not an attribute

error: could not compile `x` due to 3 previous errors

I am new to rust so I might be doing something wrong.
I did cargo init and replaced content of main.rs with example.rs and added rustyline dependency on the cargo.toml.
example.rs is from https://github.com/kkawakam/rustyline/blob/master/examples/example.rs

Cargo.toml

cat ../Cargo.toml 
[package]
name = "x"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rustyline="9.1"
rustyline-derive="0.6.0"
env_logger="0.9.0"

@gwenn
Copy link
Collaborator

gwenn commented May 30, 2022

You should not mix an example from a github master branch and a released version (9.1).
Either you use the example from master branch and the associated snapshot:

rustyline = { git = "https://github.com/kkawakam/rustyline/" }
rustyline-derive= { git = "https://github.com/kkawakam/rustyline/" }

Or you use the 0.9.1 version and the associated example from:

  • github
  • or your local repository $HOME/.cargo/registry/src/git.luolix.top-.../rustyline-9.1.2/examples/example.rs

The discrepancy comes from #621

@gwenn gwenn closed this as completed May 30, 2022
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

No branches or pull requests

2 participants