SendCode icon indicating copy to clipboard operation
SendCode copied to clipboard

SendCode cannot send codes to RStudio when upgrading RStudio to version 2022.12.0

Open LiangCZhang opened this issue 2 years ago • 13 comments

HI, I am using sublime text 4126 on Windows 10. Sendcode was working fine and can send R codes to RStudio via ctrl+enter. However, when RStudio is upgraded to version 2022.12.0 Build 353, SendCode is not working anymore. Could you have a look at this? Thanks.

LiangCZhang avatar Dec 20 '22 00:12 LiangCZhang

I can confirm this behaviour on Windows 11.

rrodrigueznt avatar Dec 20 '22 06:12 rrodrigueznt

This is the python script that controls Rstudio https://github.com/randy3k/SendCode/blob/master/code_sender/winauto.py

If someone wants to help, please follow the below steps and report what you see.

  • open python/ipython
  • run the file https://github.com/randy3k/SendCode/blob/master/code_sender/winauto.py
  • run
rid =  find_rstudio()
paste_to_rstudio(rid, from_view=False)  # this command should paste the current clipboard to Rstudio.

randy3k avatar Dec 20 '22 20:12 randy3k

Hi! On macOS 13.0.1 (22A400) now. RStudio 2022.12.0 Build 353. When in an R script, the first cmd+Enter launches RStudio, but no line will be sent afterwards.

It is the first time I have set up SendCode on Ventura. Thus I don't know if it is the new RStudio to blame or if I'm missing some step. Anyone can send an R code to Sublime working with macOS Venture?

I will try on my Windows 11 boxes early tomorrow (my time). I will also try on Ubuntu 20.04.

rrodrigueznt avatar Dec 20 '22 22:12 rrodrigueznt

From a Microsoft Windows 11 Pro Version 10.0.22621 Build 22621 running on a Dell XPS laptop:

PS C:\Users\ricar\OneDrive\Documents\Downloads> python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exec(open('./winauto.py').read())
>>> rid =  find_rstudio()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 168, in find_rstudio
Exception: window not found.
>>>

rrodrigueznt avatar Dec 21 '22 07:12 rrodrigueznt

Same result on a Windows 11 Pro 10.0.22621 Build 22621, same than above, running on a Dell OptiPlex 5080:

PS C:\Users\ricar\OneDrive\Documents\Downloads> python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exec(open('./winauto.py').read())
>>> rid =  find_rstudio()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 168, in find_rstudio
Exception: window not found.
>>>

rrodrigueznt avatar Dec 21 '22 13:12 rrodrigueznt

I'm also having issues on OS X (I'm still on 10.15.7) with Rstudio (2022.12.0+353) when trying to use SendCode. This is the error message in the SublimeText console:

subprocess.CalledProcessError: Command '['osascript', '/Users/username/Library/Application Support/Sublime Text 3/Packages/SendCode/code_sender/rstudio/rstudio.applescript', 'library(tidyverse)\nlibrary(lubridate)\nlibrary(arsenal)\nlibrary(zscorer)']' returned non-zero exit status 1

In ScriptEditor, running tell application "RStudio" to cmd "print('hello')" returns an error: A """ can't go after this identifier". Is it possible that RStudio 2022.12.0+353 doesn't support applescript (or at least the syntax used in the sendcode rstudio.applescript)?

gc5011 avatar Jan 03 '23 01:01 gc5011

@rrodrigueznt on OS X rolling back to RStudio 2022.72+576 solved the issue for me and I can send code to RStudio from sublime text. I've raised an issue in the Rstudio repo

gc5011 avatar Jan 04 '23 00:01 gc5011

RStudio has moved to electron rstudio/rstudio/wiki/Electron-Desktop.

On Mac, we use apple script to send code to RStudio and unfortunately electron doesn't support apple script. On Windows, we use native Win32 api, I beleive we just need to figure out the new window class name.

randy3k avatar Jan 04 '23 03:01 randy3k

Ah, thanks! That explains it. Does that mean for the foreseeable future there’s no way of using sublime text with SendCode on Mac to send R code to electron-based versions of RStudio? On 4 Jan 2023, 2:04 PM +1100, Randy Lai @.***>, wrote:

RStudio has moved to electron rstudio/rstudio/wiki/Electron-Desktop. On Mac, we use apple script to send code to RStudio and unfortunately electron doesn't support apple script. On Windows, we use native Win32 api, I beleive we just need to figure out the new window class name. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

gc5011 avatar Jan 04 '23 04:01 gc5011

how do you search for windows class name? i tried winlister, got "Chrome_WidgetWin_1", modified SUBLIME_PATH\Data\Packages\SendCode\code_sender\winauto.py but it doesn't work

phineas-pta avatar Jan 16 '23 13:01 phineas-pta

damn. A huge part of my workflow has just been destroyed. Guess it's time to move to neovim completely.

emilBeBri avatar Feb 15 '23 09:02 emilBeBri

Reporting the same issue. I don't like the Rstudio editor, I hope someone will help fix this. Any alternative to Sendcode?

fabeit avatar Feb 27 '23 22:02 fabeit

In the future, will there be updates for SendCode to make it support the latest RStudio? Thanks! I am using a Macbook, and I have rolled back to the older version of RStudio. However, the plot function was disabled since R has updated its graphic engine. SendCode would stop sending codes once I called a plot() function.

Sijianf avatar Oct 02 '23 01:10 Sijianf