Skip to content
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

Server failed to start probably due to hard-coded installation path ERROR #579

Closed
qqlearn123 opened this issue Oct 15, 2022 · 7 comments · Fixed by #582
Closed

Server failed to start probably due to hard-coded installation path ERROR #579

qqlearn123 opened this issue Oct 15, 2022 · 7 comments · Fixed by #582

Comments

@qqlearn123
Copy link

qqlearn123 commented Oct 15, 2022

The language server fails to start because it tries to parse an xml file in one of my R package (called xsef) and cannot find xmlTreeParse function.

I am using vscode (v1.72.2), R plugin for vscode (v2.6.0), R (v4.0.3), languageserver (v0.3.13).

The error message is like:


[2022-10-15 12:09:05:322] Error: could not find function "xmlTreeParse"
Call: xmlTreeParse(system.file("extdata/xschema.xml", package="xsef"))
Stack trace:
1: get(x, envir = ns)
2: FUN(X[[i]], ...)
3: vapply(private$objects, function(x) {
is.function(get(x, envir = ns))
}, logical(1L), USE.NAMES = FALSE)
4: initialize(...)
5: PackageNamespace$new(pkgname)
6: self$get_namespace(pkgname)
7: self$load_package(package)
8: self$workspace$load_packages(packages)
9: resolve_callack(self, uri, version, result)
10: private$callback(result)
11: task$check()
12: self$resolve_task_manager$check_tasks()
13: self$process_events()

[2022-10-15 12:09:05:322] exiting


Thanks for your help!

@renkun-ken
Copy link
Member

Looks like your package xsef defined a symbol that requires xmlTreeParse on load. Is it possible that we see the source code of xsef or would you like to share the places where you use xmlTreeParse in the package so that we could build a reproducible example?

@qqlearn123
Copy link
Author

qqlearn123 commented Oct 16, 2022

Thanks for your time looking into it.

Yes, it is indeed. There is one R file in my xsef package which have this line in it:
.xschema = xmlTreeParse(system.file("extdata/xschema.xml", package="xsef"))

Actually the xsef package depends on the XML package (which have the xmlTreeParse function), but installing and using it independently have no problem for me (since XML is loaded alongside with xsef, maybe??). Not sure how it affects the languageserver's failure to start. Maybe languageserver cannot handle this situation.

My findings so far is that:

  • For scripts which have require(xsef) directly, languageserver fails to start.
  • For scripts which have require(another), where another depends on xsef, languageserver fails to start as well.

Thanks for your help!

@renkun-ken
Copy link
Member

renkun-ken commented Oct 17, 2022

When the error occurs, is XML properly installed? Does getNamespace("xsef")$.xschema work properly in your R terminal?

Looks like xsef cannot be loaded in your case.

I create a package that defines the following

but if I remove XML, the error from package loading, not from get(x, envir = ns) as in your case:

[Error - 8:38:17 PM] Request textDocument/completion failed.
  Message: Error: there is no package called 'XML'
Call: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
Stack trace:
1: doWithOneRestart(return(expr), restart)
2: withOneRestart(expr, restarts[[1L]])
3: withRestarts(stop(cond), retry_loadNamespace = function() NULL)
4: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
5: asNamespace(ns)
6: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, 
    .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
7: loadNamespace(name)
8: getNamespace(ns)
9: asNamespace(pkgname)
10: initialize(...)
11: PackageNamespace$new(pkgname)
12: workspace$get_namespace(nsname)
13: workspace_completion(workspace, token, package, token_result$accessor == 
    "::", snippet_support)
14: completion_reply(id, uri, self$workspace, document, point, self$ClientCapabilities$textDocument$completion)
15: self$deliver(completion_reply(id, uri, self$workspace, document, 
    point, self$ClientCapabilities$textDocument$completion))
16: dispatch(self, id, params)

@qqlearn123
Copy link
Author

getNamespace("xsef")$.xschema gives me the same error - Error: could not find function "xmlTreeParse"

But, if I just type R and require(xsef), no issues. And, head(.xschema) in R terminal works fine as well.

@qqlearn123
Copy link
Author

Is there a solution or workaround to this issue? I tried lazy late loading and use XML:::xmlTreePase, both did not work.

Is it possible that the languageserver just pass through without error out in such scenario?

@renkun-ken
Copy link
Member

Would you like to try #582 and see if it works for you?

@qqlearn123 qqlearn123 changed the title Cannot parse xml document with xmlTreeParse Server failed to start probably due to hard-coded installation path ERROR Oct 26, 2022
@qqlearn123
Copy link
Author

qqlearn123 commented Oct 26, 2022

Think the original cause is hard-coded installation path which can be solved by using '--no-staged-install'.

Tried #582, it works now! Thx a lot.

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 a pull request may close this issue.

2 participants