posit-dev / positron

Positron, a next-generation data science IDE
Other
2.31k stars 68 forks source link

Using R libraries fail with pixi library #4047

Open roaldarbol opened 1 month ago

roaldarbol commented 1 month ago

Positron Version:

Version:

Positron Version: 2024.07.0 (Universal) build 59
Code - OSS Version: 1.91.0
Commit: b189a8b9c77a1fcc8a79732bfe24b2fa018436cc
Date: 2024-07-17T03:54:24.137Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin x64 23.5.0

Steps to reproduce the issue:

The issue is that trying to load or use libraries that are located in a .pixi folder. This works just fine in RStudio.

  1. Install pixi
  2. Create new R project with pixi exec copier copy gh:roaldarbol/r-template test-repo
    • Follow instructions. I used R version 4.3 (which then defaults to the 4.3.3)
    • Adding Positron when asked doesn't actually do anything yet, so it doesn't matter whether it's selected
  3. cd test-repo
  4. Add a package (for testing later, e.g. pixi add r-dplyr)
  5. Open Positron from command line (on MacOS pixi run open -a positron)
  6. Open test-repo project folder
  7. Confirm library is in path - in the console run .libPaths()
  8. Confirm that the library command can see the libraries - run library()
  9. Run library(dplyr) - see error
    • Error in library.dynam(lib, package, package.lib) : shared object ‘rlang.so’ not found
  10. Similarly, try running a command from the library - dplyr::filter()
    • Error: 'catch_cnd' is not an exported object from 'namespace:rlang'

What did you expect to happen?

I expected the library to load.

Were there any error messages in the Output panel or Developer Tools console?

Nothing suspocious in the Developer Tools Console (except that the logo doesn't load - but that's unrelated):

------------------------------------------------------------------------
workbench.js:1889 Changing where the react-dom client.js file is loaded from.
workbench.js:1890 Original path: vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/../node_modules.asar/react-dom/umd/react-dom.production.min.js/client.js
workbench.js:1891 Adjusted path: vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/react-dom/client.js
workbench.js:1896 ------------------------------------------------------------------------
positron-icon.svg:1 

       Failed to load resource: net::ERR_FILE_NOT_FOUND
workbench.desktop.main.js:131156  INFO Started local extension host with pid 41198.
workbench.desktop.main.js:131146 DEBUG No new project configuration found in storage
workbench.desktop.main.js:131146 DEBUG Using cached extensions scan result user vscode-userdata:/Users/roaldarbol/.positron/extensions/extensions.json
workbench.desktop.main.js:131146 DEBUG ComputeTargetPlatform: darwin-x64
workbench.desktop.main.js:131166  WARN Skipping extension /Users/roaldarbol/.positron/extensions/ms-vscode.js-debug-1.91.0-universal in favour of the builtin extension /Applications/Positron.app/Contents/Resources/app/extensions/ms-vscode.js-debug.
workbench.desktop.main.js:131166  WARN Skipping extension /Users/roaldarbol/.positron/extensions/quarto.quarto-1.113.0-universal in favour of the builtin extension /Applications/Positron.app/Contents/Resources/app/extensions/quarto.quarto.
workbench.desktop.main.js:131176   ERR Extension 'ms-python.python' appears in product.json but enables LESS API proposals than the extension wants.
package.json (LOSES): positronResolveSymlinks, contribEditorContentMenu, quickPickSortByLabel, testObserver, quickPickItemTooltip, terminalDataWriteEvent, terminalExecuteCommandEvent, contribIssueReporter, terminalShellIntegration
product.json (WINS): contribEditorContentMenu, quickPickSortByLabel, portsAttributes, testObserver, quickPickItemTooltip, terminalDataWriteEvent, terminalExecuteCommandEvent, contribIssueReporter, terminalShellIntegration
workbench.desktop.main.js:131166  WARN [ms-python.python]: Cannot register 'python.venvPath'. This property is already registered.
workbench.desktop.main.js:131166  WARN [vscode.positron-r]: Cannot register 'positron.r.extraArguments'. This property is already registered.
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Extension ms-python.python has been registered for language runtime for language ID 'python'
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Extension vscode.positron-r has been registered for language runtime for language ID 'r'
positron-icon.svg:1 

       Failed to load resource: net::ERR_FILE_NOT_FOUND
positron-icon.svg:1 

       Failed to load resource: net::ERR_FILE_NOT_FOUND
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Phase changed to 'starting'
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Activating extension vscode.positron-r for language ID r
workbench.desktop.main.js:131156  INFO Language runtime b6f20083579c97eff02cef099c7b7419 (language: R name: R 4.3.3 version: 4.3.3) automatically starting. Source: Affiliated r runtime for workspace
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Activating extension ms-python.python for language ID python
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Activating extension vscode.positron-r for language ID r
2workbench.desktop.main.js:131146 DEBUG [Ext host 0] Runtime manager for 'R 4.3.3': true
workbench.desktop.main.js:131146 DEBUG [Runtime startup] All extensions contributing language runtimes have been activated.
workbench.desktop.main.js:131146 DEBUG [Runtime startup] Phase changed to 'discovering'
workbench.desktop.main.js:131166  WARN Ignoring call to requestRefresh; client is not available.
workbench.desktop.main.js:131146 DEBUG [Registering Log Channel] File does not exist. Waiting for 1s to retry. file:///Users/roaldarbol/Library/Application%20Support/Positron/logs/20240717T144807/window3/exthost/vscode.jupyter-adapter/Console%20R%204.3.3.log
workbench.desktop.main.js:131156  INFO Creating positron.variables client 'positron-variables-r-0-ee953706'...
workbench.desktop.main.js:131156  INFO Creating positron.ui client 'positron-ui-r-1-5c5602bd'...
workbench.desktop.main.js:131156  INFO Creating positron.help client 'positron-help-r-2-802dd665'...
workbench.desktop.main.js:131156  INFO [perf] Render performance baseline is 27ms
workbench.desktop.main.js:131146 DEBUG suggest.durations.json {entries: Array(2), elapsed: 136.5}

PS

Could we consider adding a test for R+conda too in https://github.com/posit-dev/positron/issues/3879?

roaldarbol commented 1 month ago

Something might have broken in my system, I have the same issue in RStudio now...

roaldarbol commented 1 month ago

It seems that using Positron pushed the system-wide library in front of the project-based library. That persisted when I went back to RStudio. I removed it again with .libPaths(.libPaths()[2]). I think it was because it's not possible to open a project from the command line (#4049), then opening Positron uses a global R installation, and the library carried over and "superseded" the project library, when changing into a project even though the project had environment variables to set the libraries.

When I open RStudio, R.home() points to the pixi installation, whereas when I run R.home() in Positron, it points to the system-wide installation. So I guess Positron is not able to use a conda R installation (I knew the discovery didn't work yet, but I somehow imagined that if RStudio picked up the installation on start-up, the Positron would too)

juliasilge commented 1 month ago

Yes, I think this is related to #3724 where Positron does not know about Pixi R interpreters at all as of today. Thanks for the report!