Skip to content

Fixed typeprof.conf.json could not be loaded on VSCode on Windows #309

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

Merged
merged 4 commits into from
Apr 28, 2025

Conversation

S-H-GAMELINKS
Copy link
Contributor

@S-H-GAMELINKS S-H-GAMELINKS commented Apr 24, 2025

The problem was that the url processed by uri_to_path was like c%3A/Users/shunh/vscode-typeprof-test, and typeprof.conf.json could not be loaded.

This meant that TypeProf could be launched as an LSP, but the results of type analysis were not displayed on VSCode.

So, I changed that if %3A is included in the url returned by uri_to_path, it is replaced with :.
However, if you have any other good ways to fix it, please comment.

Note:

  • Environment
    • OS: Windows 11
    • Ruby: Ruby 3.4.3(installed by RubyInstaller)
    • VSCode 1.99.3

The problem was that the `url` processed by `uri_to_path` was like `c%3A/Users/shunh/vscode-typeprof-test`, and typeprof.conf.json could not be loaded.

This meant that TypeProf could be launched as an LSP, but the results of type analysis were not displayed on VSCode.

So, I changed that if `%3A` is included in the url returned by `uri_to_path`, it is replaced with `:`.
@mame
Copy link
Member

mame commented Apr 24, 2025

Hmm, should we use CGI.unescape_uri_component?

@S-H-GAMELINKS
Copy link
Contributor Author

Thank you for your comment.
I tried CGI.unescape_uri_component and it worked fine.
So I replaced it with that.

@mame
Copy link
Member

mame commented Apr 25, 2025

Ah, maybe we should add CGI.escape_uri_component in path_to_uri as well.
Can you check if the following implementation works on your Windows environment?

def path_to_uri(path)
  @url_schema + File.expand_path(path).split("/").map {|s| CGI.escape_uri_component(s) }.join("/")
end

def uri_to_path(url)
  uri.delete_prefix(@url_schema).split("/").map {|s| CGI.unescape_uri_component(s) }.join("/")
end

@S-H-GAMELINKS
Copy link
Contributor Author

It worked fine.
I'll commited this code.

@smasato
Copy link
Contributor

smasato commented Apr 26, 2025

Maybe the cgi gem bundled with Ruby 3.2 is the version before the CGI.escape_uri_component alias was implemented.
ruby/cgi#27
For compatibility you need to use CGI.escapeURIComponent / CGI.unescapeURIComponent.

Aside from that, TypeProf does not support Ruby 3.2 and can be excluded from the CI matrix.

@S-H-GAMELINKS
Copy link
Contributor Author

Thank you for your comment.

I thought it would be better to modify to use CGI.escapeURIComponent / CGI.unescapeURIComponent as a fix for Windows.

Also, it would be better to deal with removing Ruby 3.2 from CI as a separate issue, such as by creating a separate PR.

@smasato
Copy link
Contributor

smasato commented Apr 27, 2025

Also, it would be better to deal with removing Ruby 3.2 from CI as a separate issue, such as by creating a separate PR.

I think so too.
I created #313 .

@mame mame merged commit d86c97b into ruby:master Apr 28, 2025
7 checks passed
@mame
Copy link
Member

mame commented Apr 28, 2025

Thanks!

@S-H-GAMELINKS S-H-GAMELINKS deleted the fix/windows-folder-path branch April 28, 2025 03:58
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

Successfully merging this pull request may close these issues.

3 participants