scry icon indicating copy to clipboard operation
scry copied to clipboard

Error reading file: Is a directory

Open faustinoaq opened this issue 6 years ago • 6 comments

Hi, seems completion feature is including directories in some wrong places :sweat_smile:

I found this strange error when I was working on other unrelated features:

D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : Content-Length: 281
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : 
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : {"jsonrpc":"2.0","id":23,"method":"completionItem/resolve","params":{"label":"bar/","detail":"bar/","filterText":"bar/","insertTextFormat":1,"insertText":"bar/","kind":9,"sortText":"bar/","data":{"require_module_context":true,"path":"/home/main/Projects/console/src/console/bar"}}}
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : completionItem/resolve
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : Content SEND: Content-Length: 1215

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Error reading file: Is a directory","data":["/usr/lib/crystal/io/file_descriptor.cr:53:9 in 'unbuffered_read'","/usr/lib/crystal/io/buffered.cr:206:5 in 'fill_buffer'","/usr/lib/crystal/io/buffered.cr:82:7 in 'peek'","/usr/lib/crystal/io.cr:638:37 in 'gets'","/usr/lib/crystal/io.cr:611:5 in 'gets'","/usr/lib/crystal/io.cr:581:5 in 'gets'","/usr/lib/crystal/io.cr:580:3 in 'gets'","/usr/lib/crystal/io.cr:1167:7 in 'next'","/usr/lib/crystal/iterator.cr:913:9 in 'next'","/usr/lib/crystal/enumerable.cr:390:15 in 'join'","/usr/lib/crystal/enumerable.cr:620:7 in 'join'","/home/main/Projects/scry/src/scry/completion_resolver.cr:11:9 in 'run'","/home/main/Projects/scry/src/scry/context.cr:103:19 in 'dispatch_request'","/home/main/Projects/scry/src/scry/context.cr:31:7 in 'dispatch'","/home/main/Projects/scry/src/scry.cr:25:19 in 'start'","/home/main/Projects/scry/src/scry.cr:42:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}

/cc @laginha87

faustinoaq avatar Apr 09 '18 06:04 faustinoaq

@laginha87 I'm trying to solve this issue, but I can't figure out why is this still happening, Do you have some idea? :sweat_smile:

Received message which is neither a response nor a notification message:
{
    "jsonrpc": "2.0",
    "error": {
        "code": -32001,
        "message": "Error reading file: Is a directory",
        "data": [
            "/usr/lib/crystal/io/file_descriptor.cr:53:9 in 'unbuffered_read'",
            "/usr/lib/crystal/io/buffered.cr:206:5 in 'fill_buffer'",
            "/usr/lib/crystal/io/buffered.cr:82:7 in 'peek'",
            "/usr/lib/crystal/io.cr:638:37 in 'gets'",
            "/usr/lib/crystal/io.cr:611:5 in 'gets'",
            "/usr/lib/crystal/io.cr:581:5 in 'gets'",
            "/usr/lib/crystal/io.cr:580:3 in 'gets'",
            "/usr/lib/crystal/io.cr:1167:7 in 'next'",
            "/usr/lib/crystal/iterator.cr:913:9 in 'next'",
            "/usr/lib/crystal/enumerable.cr:390:15 in 'join'",
            "/usr/lib/crystal/enumerable.cr:620:7 in 'join'",
            "/home/main/Projects/scry/src/scry/completion_resolver.cr:11:9 in 'run'",
            "/home/main/Projects/scry/src/scry/context.cr:115:19 in 'dispatch_request'",
            "/home/main/Projects/scry/src/scry/context.cr:27:7 in 'dispatch'",
            "/home/main/Projects/scry/src/scry.cr:22:18 in 'start'",
            "/home/main/Projects/scry/src/scry.cr:38:1 in '__crystal_main'",
            "/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'",
            "/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'",
            "/usr/lib/crystal/crystal/main.cr:101:7 in 'main'",
            "/usr/lib/crystal/crystal/main.cr:135:3 in 'main'",
            "__libc_start_main",
            "_start",
            "???"
        ]
    }
}

faustinoaq avatar May 18 '18 03:05 faustinoaq

when does this happen, is it when you open the workspace or a specific file ? Two sections where this might happen are: https://github.com/crystal-lang-tools/scry/blob/b38f2df6c2da71d69589bad177a38558912f5bda/src/scry/completion/method_db.cr#L23

and here https://github.com/crystal-lang-tools/scry/blob/b38f2df6c2da71d69589bad177a38558912f5bda/src/scry/completion/dependency_graph.cr#L124

laginha87 avatar May 18 '18 08:05 laginha87

is it when you open the workspace or a specific file ?

@laginha87 Not a specific file, but any file inside src directory.

Code Completions works fine, though, this error is a bit annoying :sweat_smile: (fill up my logs)

Maybe this error is caused by some dir inside lib or crystal path, WDYT?

faustinoaq avatar May 18 '18 13:05 faustinoaq

I think we can try to check if file is actually a file? before analyzing it :sweat_smile:

Ref: File.file?

faustinoaq avatar May 18 '18 13:05 faustinoaq

can you check if adding that check here https://github.com/crystal-lang-tools/scry/blob/b38f2df6c2da71d69589bad177a38558912f5bda/src/scry/completion/dependency_graph.cr#L112 fixes the issue ?

laginha87 avatar May 19 '18 09:05 laginha87

can you check if adding that check here fixes the issue ?

No, it don't

is it when you open the workspace or a specific file ?

I was wrong, this only happens when I have a file and a directory with similar name, like this:

screenshot_20180519_115650

:sweat_smile:

faustinoaq avatar May 19 '18 17:05 faustinoaq