12

Okay, this is driving my crazy. I had set this up before, deleted Sublime Text, and now I can't remember what the right configuration was.

Very simple: I'm running R through SublimeREPL and need to point the REPL to where R is installed.

I followed the directions at http://sublimerepl.readthedocs.org/en/latest/, which say to go into the user-defined REPL settings and add this:

{
 ...
 "default_extend_env": {"PATH": "{PATH}:/home/myusername/bin"}
 ...
} 

where the path points to the right directory. I tried replacing it with

{
 ...
 "default_extend_env": {"PATH": "C:/Program Files/R/R-3.0.2/bin"}
 ...
}

and it's still unable to find R, plus now it's giving me the error:

Error trying to parse settings: Expected value in Packages\User\SublimeREPL.sublime-     settings:2:2

I know this is an easy fix. Can anybody point out what I'm doing wrong here?


*I'm using Sublime Text 3. I previously had this working, but on Sublime Text 2.

Community
  • 1
  • 1
Marc Tulla
  • 1,751
  • 2
  • 20
  • 34

2 Answers2

16

Go to Preferences -> Browse Packages... and create a directory tree User/SublimeREPL/config/R. In that directory, create a new file named Main.sublime-menu with the following contents:

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "r",
            "id": "SublimeREPL",
            "children":
            [
                {"command": "repl_open",
                 "caption": "Rterm",
                 "id": "repl_r",
                 "mnemonic": "r",
                 "args": {
                    "type": "subprocess",
                    "external_id": "r",
                    "additional_scopes": ["tex.latex.knitr"],
                    "encoding": {"windows": "$win_cmd_encoding"},
                    "soft_quit": "\nquit(save=\"no\")\n",
                    "cmd": {"windows": ["C:/Program Files/R/R-3.0.2/bin/x64/Rterm.exe", "--ess", "--encoding=$win_cmd_encoding"]},
                    "cwd": "$file_path",
                    "extend_env": {"windows": {"PATH": "{PATH}:/C/Program Files/R/R-3.0.2/bin"}},
                    "cmd_postfix": "\n",
                    "suppress_echo": {"windows": false},
                    "syntax": "Packages/R/R.tmLanguage"
                    }
                }
            ]
        }]
    }
]

Save the file, and you should now have a Tools -> SublimeREPL -> Rterm menu option. Double-check that the path is the correct one to the Rterm.exe file. On my computer (32-bit XP) it's in the i386 subfolder of bin, so yours may be in bin/x64 or something like that.

I hope this helps, let me know if you still have issues.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • Thanks! I'm running into major issues with this. 1) When I go to Preferences --> Browse Packages, there are two folders: One for User and another for SublimeREPL. So the SublimeREPL folder isn't in the User folder. So I created another path under User, as you described, and added the Main.sublime-menu file with those contents. But when I load Sublime afterwards, R is not even an option under SublimeREPL. 2) Rather than creating a new path as you mentioned, I just went and moved the SublimeREPL folder (that already has all the User/SublimeREPL/config stuff in it) into the "User" path – Marc Tulla Jan 14 '14 at 23:35
  • @MarcTulla - don't move, just copy. – MattDMo Jan 14 '14 at 23:40
  • @MarcTulla I made a minor mistake in my answer, there won't be a separate `R` submenu, but you should have an `Rterm` option if you created `User/SublimeREPL/config/R/Main.sublime-menu` with the contents I gave you. Is that not showing up? – MattDMo Jan 14 '14 at 23:41
  • Please [join me in chat](http://chat.stackoverflow.com/rooms/45232/21115295) so we don't clutter the comments with troubleshooting... – MattDMo Jan 14 '14 at 23:44
  • In more recent versions of R, maybe only 64bit builds, there is only `R.exe` – Hedgehog Sep 13 '17 at 00:53
0

I resolved this by adding the location of Rterm.exe to PATH

user2723494
  • 1,168
  • 2
  • 15
  • 26