Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

error: file not found for module #155

Closed
martinlindhe opened this issue Mar 19, 2017 · 31 comments
Closed

error: file not found for module #155

martinlindhe opened this issue Mar 19, 2017 · 31 comments

Comments

@martinlindhe
Copy link

Version of VSCode: 1.10.2
Version of the extension: 0.3.10
OS: macOS / Linux

Description: adding a whitespace & save src/main.rs to trigger rustfmt gives error, while "cargo check" sees no error. I dont see this behaviour with other files in the project than src/main.rs

Output of the "Rust logging" channel:

DEBUG: Language Client Manager: start

However, more is shown in the "Rust Language Server" channel:

error: file not found for module `app`
  --> stdin:45:5
   |
45 | mod app;
   |     ^^^
   |
   = help: name the file either app.rs or app/mod.rs inside the directory ""

[Error - 10:09:38 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32601 

I originally reported this issue in the rls project here, but they tell me their reference plugin doesn't exhibit this behaviour, so I'm re-submitting the issue here.

--

Hello, I am seeing an issue from rls, using the vscode-rust plugin.

I reproduced it on Linux and OSX like this:

git clone https://github.com/BurntSushi/ripgrep
cd ripgrep
code .
[navigate to src/main.rs]
[add a whitespace and save, to trigger rls]

gives the following error:

error: file not found for module `app`
  --> stdin:45:5
   |
45 | mod app;
   |     ^^^
   |
   = help: name the file either app.rs or app/mod.rs inside the directory ""

[Error - 6:01:04 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32601 

there is a file src/app.rs in the project.
the code compiles correctly using "cargo build".

Intellisense and code navigation appears to work in the other files, this just seems to happen while in src/main.rs

Using rls from git of today (91a4b57), set up like this:

git clone https://github.com/rust-lang-nursery/rls.git
cd rls
rustup update
rustup default nightly
cargo install
# on linux:
export LD_LIBRARY_PATH="$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"
export RLS_ROOT="$HOME/dev/rs/rls"

rustup component add rust-analysis

and added the following vscode-rust configuration:

    "editor.formatOnSave": true,
    "rust.rls": {
        "executable": "rustup",
        "args": [
            "run",
            "nightly",
            "rls"
        ]
    },
@KalitaAlexey
Copy link
Member

I am looking at this issue.

@martinlindhe
Copy link
Author

I gave this another shot today, rebuilt rls from git master and updated rustup. The issue appears to have disappeared!

@KalitaAlexey Could you reproduce it?

Also I think I forgot to mention i used the vscode-rust version as published in vscode extensions, did not compile this project manually. I see there's been some activity since the last release, possible to tag a new point release?

@martinlindhe
Copy link
Author

Hm, actually I see it again. Will try to build this extension from source to rule out if recent commits have resolved it.

I think the stdin:45:5 in the original post is a hint. If rls gets piped raw text without context, of course it cannot know about the other modules referenced.

@martinlindhe martinlindhe reopened this Mar 30, 2017
@martinlindhe
Copy link
Author

martinlindhe commented Mar 30, 2017

Struggling to compile...

$ npm install -dev
$ node ./node_modules/typescript/bin/tsc -p .
$ node ./node_modules/vscode/bin/install
Error installing vscode.d.ts: Missing VSCode engine declaration in package.json.

Not exactly sure how to use all these gulps and npms and typescripts in this particular project.

How would one trigger the creation of a vsix archive to feed into vscode?

@KalitaAlexey
Copy link
Member

@martinlindhe,
Basically it is enough to run:

npm install
vsce package

@KalitaAlexey
Copy link
Member

@martinlindhe,
I am closing this issue since there was no any response for a long time.
If you are still experiencing this issue, please open this issue again and details which we discussed.

@martinlindhe
Copy link
Author

I abandoned use of vscode-rust for the time being because of this issue. Am currently trying out https://github.com/jonathandturner/rls_vscode which is working better, but lacks some other features such as rustfmt. Thanks for your time

@KalitaAlexey
Copy link
Member

@martinlindhe,
Could you try it again because at some point this extension will be the main one.

@cksac
Copy link

cksac commented Apr 20, 2017

@KalitaAlexey I have similar issue with RLS mode also..

Version of VSCode: 1.11.2
Version of the extension: 0.3.11
OS: macOS (10.12.4)

rls.toml

build_lib = true
unstable_features = true

Description:
src/shape.rs exists but get following error when formating src/lib.rs.
while formatting modules(e.g. shape.rs) is fine.

error: file not found for module `shape`
 --> stdin:5:9
  |
5 | pub mod shape;
  |         ^^^^^
  |
  = help: name the file either shape.rs or shape/mod.rs inside the directory ""

[Error - 11:23:54 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32601 

@sethlopezme
Copy link

sethlopezme commented Apr 22, 2017

I, too, am seeing this issue. The modules that I'm getting an error for are present and I can build my code successfully. This issue appears to happen anywhere there is a mod <module>;.

VS Code 1.11.2
vscode-rust 0.3.11
macOS 10.12.4

# rls.toml
unstable_features = true
// db/mod.rs
use std::env;

use diesel::pg::PgConnection;
use r2d2;
use r2d2_diesel::ConnectionManager;

pub type Pool = r2d2::Pool<ConnectionManager<PgConnection>>;

pub fn init_pool() -> Pool {
    let database_url = env::var("DATABASE_URL").expect("environment variable DATABASE_URL must be set");
    let config = r2d2::Config::default();
    let manager = ConnectionManager::<PgConnection>::new(database_url);
    r2d2::Pool::new(config, manager).expect("unable to create database pool")
}

pub mod schema;
pub mod model;
error: file not found for module `schema`
  --> stdin:16:9
   |
16 | pub mod schema;
   |         ^^^^^^
   |
   = help: name the file either schema.rs or schema/mod.rs inside the directory ""

[Error - 12:04:56 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32601 

@KalitaAlexey
Copy link
Member

@sethlopezme, What OS?

@sethlopezme
Copy link

@KalitaAlexey macOS 10.12.4

@KalitaAlexey
Copy link
Member

I am downloading Ubuntu ISO.
I will try this on Linux.
If I the problem didn't occur on Linux, I suppose someone who has Linux would have to do it himself.
Anyway @sethlopezme,
Could you try rls_vscode and say if no problem there.

@sethlopezme
Copy link

sethlopezme commented Apr 22, 2017

@KalitaAlexey I ran rls_vscode and I didn't see any errors in the output/debug console. I haven't run rls_vscode before but I assume that's where I would look for errors. Let me know if I need to look elsewhere for them.

@KalitaAlexey
Copy link
Member

@sethlopezme,
vscode-rust and rls_vscode differently start RLS.
I will implement starting as rls_vscode does.

@sethlopezme
Copy link

I actually had difficulty with rls_vscode. I have RLS installed through rustup, but the only way I could get it to work with rls_vscode was to pull the RLS source down and set the RLS_ROOT environment variable.

@KalitaAlexey
Copy link
Member

Why couldn't you start RLS from rustup?

@sethlopezme
Copy link

Well, for a very good reason. The reason being that I'm an idiot and for some strange reason I didn't realize it worked that way. It all makes sense now, ha.

@KalitaAlexey
Copy link
Member

@sethlopezme,
Will you test a code from a branch which I will tell you?

@KalitaAlexey
Copy link
Member

The branch is spawn-rls-how-rls-vscode-does
I want you to try it out.
If your problem fixed, I would commit it.
I really hope it will be fixed.

@sethlopezme
Copy link

Is there anything specific that I need to do? I pulled the repo down, checked out the spawn-rls-how-rls-vscode-does branch and ran it with Debug, but it didn't look like anything was happening. I tried this both with and without RLS running beforehand.

@KalitaAlexey
Copy link
Member

@sethlopezme,
You should run either extension and try to cause your problem.

@sethlopezme
Copy link

I guess what I'm asking is if there is anything specific that I need to do to get RLS working on the spawn-rls-how-rls-vscode-does branch. When I tried to use the plugin from that branch, RLS did not appear to start, so I then tried running the plugin with RLS running from the command line, but the plugin still didn't do anything for me - no RLS analysis status in the status bar, no code completion, etc.

@KalitaAlexey
Copy link
Member

It strange.
It should work.
Could you provide the Output Channel log?

@sethlopezme
Copy link

sethlopezme commented Apr 25, 2017

Ah, here we go. My apologies - the first time I tried running the extension, I had forgotten to run npm install beforehand. With that being said, I do get an error when trying to run the extension with Debug.

As a reminder, here are my versions:

  • VS Code: 1.11.2
  • Extension: latest spawn-rls-how-rls-vscode-does branch
  • Node: v.7.9.0
  • OS: macOS 10.12.4

In the Debug Console tab of the main VS Code window, I saw this:

Activating extension `kalitaalexey.vscode-rust` failed: Cannot find module '/Users/sethlopez/personal/vscode-rust/out/src/extension'.
Activating extension `kalitaalexey.vscode-rust` failed:  Cannot find module '/Users/sethlopez/personal/vscode-rust/out/src/extension'
Here is the error stack:  Error: Cannot find module '/Users/sethlopez/personal/vscode-rust/out/src/extension'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Function.U.J.i._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:374834)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Function.s [as __$__nodeRequire] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:25882)
    at d (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:375989)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:380927
    at then (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:54659)
    at t._doActualActivateExtension (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:4:380887)

In the Output tab of the main VS Code window, I saw this:

11:18:20 AM - File change detected. Starting incremental compilation...
src/components/language_client/manager.ts(30,13): error TS2345: Argument of type 'string[] | undefined' is not assignable to parameter of type 'string[]'.
  Type 'undefined' is not assignable to type 'string[]'.
11:18:20 AM - Compilation complete. Watching for file changes.

@KalitaAlexey
Copy link
Member

@sethlopezme,
Pull this branch and try again.
I have no idea how it worked for me)

@sethlopezme
Copy link

sethlopezme commented Apr 25, 2017

@KalitaAlexey Ah, that allowed the plugin to function for me. I still experienced an issue, though. It saw that I have rustup installed, but it says that I don't have RLS installed (I do, through rustup).

@KalitaAlexey
Copy link
Member

KalitaAlexey commented Apr 25, 2017

@sethlopezme,
It showed that it couldn't see RLS
You configured it using rust.rls.
You tried to cause the problem.
The problem happened.
Is that right?

@KalitaAlexey
Copy link
Member

I have no idea then.

@sethlopezme
Copy link

I think this is an RLS issue. I was just able to reproduce it in rls_vscode.

@KalitaAlexey
Copy link
Member

You should open an issue in RLS's repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants