mtshiba / pylyzer

A fast, feature-rich static code analyzer & language server for Python
http://mtshiba.github.io/pylyzer/
MIT License
2.44k stars 32 forks source link

[Install] Error installing with cargo: Unresolved import #85

Closed Neah-Ko closed 1 week ago

Neah-Ko commented 6 months ago

Hello,

Today I learned about the existence of this package and wanted to try vscode extension.

Then after git clone https://github.com/mtshiba/pylyzer.git:

user@debian:path/to/pylyzer$ cargo install --path .
  Installing pylyzer v0.0.52 (path/to/pylyzer)
    Updating crates.io index
    Updating git repository `https://github.com/RustPython/Parser`
   Compiling py2erg v0.0.52 (path/to/pylyzer/crates/py2erg)
error[E0432]: unresolved imports `erg_compiler::erg_parser::ast::Array`, `erg_compiler::erg_parser::ast::NormalArray`, `erg_compiler::erg_parser::ast::ArrayComprehension`
  --> crates/py2erg/convert.rs:11:21
   |
11 |     Accessor, Args, Array, BinOp, Block, ClassAttr, ClassAttrs, ClassDef, ConstAccessor, ConstArgs,
   |                     ^^^^^ no `Array` in `ast`
...
14 |     LambdaSignature, Literal, Methods, Module, NonDefaultParamSignature, NormalArray, NormalDict,
   |                                                                          ^^^^^^^^^^^ no `NormalArray` in `ast`
...
19 |     VisModifierSpec, ArrayComprehension, SetComprehension,
   |                      ^^^^^^^^^^^^^^^^^^
   |                      |
   |                      no `ArrayComprehension` in `ast`
   |                      help: a similar name exists in the module: `ListComprehension`

error[E0599]: no variant or associated item named `Array` found for enum `erg_compiler::erg_parser::ast::Expr` in the current scope
    --> crates/py2erg/convert.rs:1151:33
     |
1151 |                 let arr = Expr::Array(Array::Normal(NormalArray::new(l_sqbr, r_sqbr, elems)));
     |                                 ^^^^^ variant or associated item not found in `Expr`
     |
note: if you're trying to build a new `erg_compiler::erg_parser::ast::Expr` consider using one of the following associated functions:
      erg_compiler::erg_parser::ast::Expr::local
      erg_compiler::erg_parser::ast::Expr::dummy_local
      erg_compiler::erg_parser::ast::Expr::static_local
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/erg_parser-0.6.34/ast.rs:5980:5
     |
5980 |     pub fn local(name: &str, lineno: u32, col_begin: u32, col_end: u32) -> Self {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
5990 |     pub fn dummy_local(name: &str) -> Self {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
5994 |     pub fn static_local(name: &'static str) -> Self {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no variant or associated item named `Array` found for enum `erg_compiler::erg_parser::ast::Expr` in the current scope
    --> crates/py2erg/convert.rs:1171:33
     |
1171 |                 let arr = Expr::Array(Array::Comprehension(ArrayComprehension::new(l_sqbr, r_sqbr, Some(layout), generators, guard)));
     |                                 ^^^^^ variant or associated item not found in `Expr`
     |
note: if you're trying to build a new `erg_compiler::erg_parser::ast::Expr` consider using one of the following associated functions:
      erg_compiler::erg_parser::ast::Expr::local
      erg_compiler::erg_parser::ast::Expr::dummy_local
      erg_compiler::erg_parser::ast::Expr::static_local
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/erg_parser-0.6.34/ast.rs:5980:5
     |
5980 |     pub fn local(name: &str, lineno: u32, col_begin: u32, col_end: u32) -> Self {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
5990 |     pub fn dummy_local(name: &str) -> Self {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
5994 |     pub fn static_local(name: &'static str) -> Self {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `py2erg` (lib) due to 3 previous errors
error: failed to compile `pylyzer v0.0.52 (/path/to/pylyzer)`, intermediate artifacts can be found at `/path/to/pylyzer/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

System info:

$ uname -a
Linux debian 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux
$ rustc --version
rustc 1.77.2 (25ef9e3d8 2024-04-09)
$ cargo --version
cargo 1.77.2 (e52e36006 2024-03-26)
$ python --version
Python 3.11.2

I found no matching issue for this. Should I downgrade pylyzer version ?

EDIT: Browsing some issue, I found that I needed to install ERG and set ERG_PATH, which I've done that way:


git clone https://github.com/erg-lang/erg.git
cd erg
cargo build --release
Cloning into 'erg'...
remote: Enumerating objects: 39190, done.
remote: Counting objects: 100% (1928/1928), done.
remote: Compressing objects: 100% (687/687), done.
remote: Total 39190 (delta 1270), reused 1866 (delta 1236), pack-reused 37262
Receiving objects: 100% (39190/39190), 15.97 MiB | 6.23 MiB/s, done.
Resolving deltas: 100% (29475/29475), done.
    Updating crates.io index
  Downloaded quote v1.0.35
  Downloaded proc-macro2 v1.0.79
  Downloaded smallvec v1.13.1
  Downloaded autocfg v1.1.0
  Downloaded 4 crates (123.6 KB) in 0.21s
   Compiling libc v0.2.153
   Compiling autocfg v1.1.0
   Compiling parking_lot_core v0.9.9
   Compiling proc-macro2 v1.0.79
   Compiling unicode-ident v1.0.12
   Compiling syn v1.0.109
   Compiling erg_common v0.6.35-nightly.0 (/path/to/erg/crates/erg_common)
   Compiling cfg-if v1.0.0
   Compiling smallvec v1.13.1
   Compiling scopeguard v1.2.0
   Compiling once_cell v1.19.0
   Compiling unicode-xid v0.2.4
   Compiling thread_local v1.1.8
   Compiling lock_api v0.4.11
   Compiling quote v1.0.35
   Compiling parking_lot v0.12.1
   Compiling erg_proc_macros v0.6.35-nightly.0 (/path/to/erg/crates/erg_proc_macros)
   Compiling erg_compiler v0.6.35-nightly.0 (/path/to/erg/crates/erg_compiler)
   Compiling erg v0.6.35-nightly.0 (/path/to/erg)
   Compiling erg_parser v0.6.35-nightly.0 (/path/to/erg/crates/erg_parser)
   Compiling erg_linter v0.6.35-nightly.0 (/path/to/erg/crates/erg_linter)
    Finished release [optimized] target(s) in 2m 25s

and export ERG_PATH=/path/to/erg Which didn't changed to error.

EDIT 2: After a systemwide find, I set ERG_PATH=/home/user/.erg/ instead, but it didn't worked either.

aarnros commented 6 months ago

Using cargo install --locked --path=. worked for me https://github.com/mtshiba/pylyzer/issues/78#issuecomment-2022917309

Neah-Ko commented 6 months ago

Using cargo install --locked --path=. worked for me #78 (comment)

Thanks @aarnros the installation did proceed that way.

However, at first glance it doesn't seem that pylyzer (or the vscode extension) is production grade yet.

In the first few seconds of use I can notice that:

And finally after opening few files from my project to write this review I get this popup:

image

mtshiba commented 1 week ago

Please build using cargo install --path . --locked. Most of the issues you pointed out have been fixed in the latest version.