Closed Leemur89 closed 1 month ago
nvm is based on node but it is not node.
did you install node? and where did you install node?
did you call rfbrowser init
after installing the Browser library? does this work?
How you start vscode, is node in PATH?
maybe, after installing all needed libraries/packages a restart of your computer is needed, mostly a logoff / login is enough, so that all PATHs are initialized correctly.
From vscode terminal (with my venv):
$ which node
/Users/***/.nvm/versions/node/v18.19.0/bin/node
$ rfbrowser init chromium [11:14:29]
2024-08-22 11:14:52,792 [INFO ] ==============================================================================================================
2024-08-22 11:14:52,792 [INFO ] Installing node dependencies...
2024-08-22 11:14:53,701 [INFO ] Installing rfbrowser node dependencies at /Users/***/Documents/project/.venv/lib/python3.8/site-packages/Browser/wrapper
2024-08-22 11:14:53,869 [INFO ] npm WARN config production Use `--omit=dev` instead.
2024-08-22 11:14:55,333 [INFO ]
2024-08-22 11:14:55,333 [INFO ] added 67 packages, and audited 68 packages in 1s
2024-08-22 11:14:55,333 [INFO ]
2024-08-22 11:14:55,333 [INFO ] 8 packages are looking for funding
2024-08-22 11:14:55,333 [INFO ] run `npm fund` for details
2024-08-22 11:14:55,334 [INFO ]
2024-08-22 11:14:55,334 [INFO ] found 0 vulnerabilities
2024-08-22 11:14:55,338 [INFO ]
2024-08-22 11:14:55,339 [INFO ] Installing browser chromium binaries to /Users/***/Documents/project/.venv/lib/python3.8/site-packages/Browser/wrapper
2024-08-22 11:14:55,339 [INFO ] npx --quiet playwright install chromium
2024-08-22 11:15:22,759 [INFO ] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■| 100% of 1 MiB
2024-08-22 11:15:22,820 [INFO ]
2024-08-22 11:15:22,820 [INFO ] rfbrowser init completed
2024-08-22 11:15:22,820 [INFO ] ==============================================================================================================
So yes I have node in my path and I ran rfbrowser init
, I'll give a try on the reboot.
edit still the same after a reboot. Also tried a global install of node using brew install node
. Still the same...
did you try to execute the command `RobotCode: Clear Cache and Restart Language Servers"?
yup multiple times
Also rfbrowser clean-node
followed by rfbrowser init
ok, because nvm is running on the shell. did you call the nvm
command before calling rfbrowser init
?
did you try to open vscode from terminal/shell where you call nvm before?
I do not know nvm, so that's why I'm asking. Is there a way to put you node installation to the system/userpath without starting a shell? I know this from pyenv, there is a shim folder, where you can manage the default user python, the only thing you have to do ist, to put it into the userpath. There is an nvm alias
command, maybe this?
If I run a python from my terminal with my venv it is working fine:
$ python
Python 3.8.19 (default, Aug 20 2024, 11:17:47)
[Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import run
>>> run(["node", "-v"], check=True)
v18.19.0
CompletedProcess(args=['node', '-v'], returncode=0)
I suspect the issue on the PATH not being properly set up in the LSP
Actually nvm is setting for me the node globally in my system, so from any terminal I got the node
with the version I've set with nvm (here 18.19.0)
yes, because nvm is running in the .bashrc or .zshrc, but if you start vscode, vscode is started without a shell, so the nvm script is not started. And yes, if you open a terminal in vscode a full shell is started, but vscode/lsp does not know what is started in this shell.
So you need to set/update the paths with nvm before you start vscode.
I closed VSCode, then launched it with the command code
from a terminal as you suggested, and now it works, thanks!
I just need to be careful next time, as it stays in cache: if I close VSCode and open it the classical way (from applications), it will still work because lib will be in cache. And then it will fail again on the next 'Clear Cache and reload LSP'
I think a neat improvement would be on the rfbrowser library to perform the node check only in "run" mode (there is some boolean on RF to know whether we are on dryrun/static analysis vs actual run which could be used to smartly bypass the node check), I'll try to raise an MR to them
Anyway, thank you for your quick support !
Describe the bug Hello, Robotcode cannot import the browser library as it fails to find node
To Reproduce Steps to reproduce the behavior:
Browser is highlighted and following error is displayed (note that I manually edited the playwright.py file to dump the content of the PATH, which shows
/usr/bin:/bin:/usr/sbin:/sbin
and not my virtual env):Expected behavior Library is imported
Logs Robotcode output:
Robotcode LSP output:
Desktop (please complete the following information):
Additional context I did as you suggested here but this did not change anything :/
Note that I'm using nvm, can this interfere?
Thanks