-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
invalid byte sequence in US-ASCII #33
Comments
Is there a particular file that gives you this error? The most likely cause is a literal string with escaped characters, e.g., I'm not able to reproduce this error in Windows. I'll try on MacOS later. |
@castwide - I'm guessing that we've got something like that somewhere in the code base, but unfortunately the error message just isn't specific about where the error occurred. The project is ~250K lines of code in ~2K .rb files, not including gems, etc... |
No problem. Even in the unlikely event that I can't reproduce the error, at least I can add the name of the offending file to the message. |
But is there a way to ignore it in the future? I mean I can't just go and add #encoding to any file in the project solargraph finds offending. |
Yes, I think I can make the parser ignore it. There are already similar character encoding issues that it's able to resolve. I'll still make it report the file name in the event of an edge case it can't handle. |
Reproduced on MacOS. I'm looking into solutions. |
A fix is pushed to the master branch. The parser should never fail. Even if the file isn't valid Ruby code, Solargraph should add it to the workspace and report the problems in diagnostics. Character encoding should be a non-issue. It's possible for Ruby code to contain string literals with invalid characters, but Solargraph shouldn't care as long as it doesn't try to write back to the file, which it never does. I'll update the gem in the next day or so. |
Version 0.18.3 is published. |
Thanks @castwide, instead of the original error, I now receive Would you prefer I open a new issue on this? |
@JeffLuckett Are you still getting that error in the current version (0.19.1)? |
@castwide - no, now I get: However, I've only got about 2K files in the repo that are .rb files. => git ls-files | grep .rb | wc -l
1981 |
Do you have a .solargraph.yml file? If so, does the |
There is no .solargraph.yml file in my project root, or in my home dir. |
Is the project root your open folder in VSCode? Solargraph treats whatever folder you open as the workspace. Does the project have cache or vendor/cache directories, or something similar that contains bundled gems? If so, you might need to create a .solargraph.yml and add them to the Also, this command should give you a more accurate idea of what gets added to the workspace:
The default is to include all ruby files except the |
I did Thanks for sticking with me on this :D |
Glad you got it working. This made me think of two more items for the to-do list.
|
This issue is resolved, thanks again ... closing. |
Hi! I was wondering if I found an edge case. I'm using Solargraph's 0.21 version and I am still getting this error. This is a huge codebase though (about 9k Ruby files). I've reduced the count to less than 5000 to make the server work, but I still struggle to get it working, since I'm finding a lot of non-ASCII characters in form of comments, tests, etc. After looking for a way to check what non ASCII characters are present in my codebase, I got the following:
The stuff I found are characters like These are contained in Ruby files, so I can't just get rid of them (we're specifically testing for issues with those characters, so I can't change the code to remove that). I also notice that autocompletion still works, but it works in a very barebones way — no inline documentation, no differentiation between methods, constants, variables, etc., no symbol information for Ruby files, etc.). I am using VS Code, if this helps, on Mac OS X 10.12.6.
|
Similar error. I started to get "Invalid byte sequence in Windows-31J" after some recent update.
|
Hi! |
@tekknovator Can you provide a minimal example that triggers the error? I've found at least one bug in how certain UTF-8 characters get handled (including "¬"), but it doesn't make the server fail to start. |
Problem seems to appear again with version 0.31.0 of solargraph gem. I downgraded to version 0.30.2 and solargraph-server starts inside atom. |
Thanks, I experienced this with a rails project today using solargraph-0.31.3. Downgrading to 0.30.2 fixed the issue. Is there anyway to view output of which files solargraph is parsing when it hits the invalid byte sequence and crashes? |
@AlanWarren I'm working on an update that will report which file triggered the error. Hopefully it will also be able to skip offending files and parse the rest of the workspace. Can anyone who's experiencing this error let me know if there's a backtrace or any additional information in the console log? (In VS Code, Help -> Toggle Developer Tools; in Atom, View -> Developer -> Toggle Developer Tools.) |
@castwide I just sent the console-output via email to you. |
Thanks, @kkneutgen. That was exactly what I needed. I was able to trace the problem to a regular expression match that choked on invalid character encoding. To reproduce the error, I created a file that contained UTF-8 (e.g., '¬'), converted its contents to ANSI with an external tool, and ran the file through the Solargraph source mapper. I think I'll be able to have a fix for this in the next minor release. |
The master branch has an update that might resolve this issue. It fixes the problem in the variation of the error I reproduced yesterday. |
One more change: exceptions during the mapping process will emit warnings that identify the file where the problem occurred. |
Gem v0.32.0 includes the latest fix for invalid byte sequences and the new mapper exception handling. |
Great, thank you. No more problems with strange encodings here. |
Works here as well now. Sorry for not responding earlier. I used the characters inside of a heredoc. |
I'm getting the same error in version 0.37.2. Only version I can get to work is 0.31.3.
|
@sent-hil Can you give me a simple example of a file that causes the error, the character set it uses, and a sequence of steps to cause it if it doesn't happen on startup? I haven't been able to reproduce it. |
I see
Example:
|
For what it's worth to other googlers, I was getting the following error in VS-Code, with Solargraph 0.40.2: And I traced the problem to a ruby file containing a non-ASCII character in a comment - � |
Environment Info:
MacOS High Sierra
VS Code: 1.22.1 (1.22.1)
Solargraph Gem: 0.18.1
Ruby Solargraph Plugin: 0.14.1
Ruby: 2.4.1p111 (Large-ish Rails app)
Let me know if you need more info, or if you have any suggestions.
The text was updated successfully, but these errors were encountered: