stencila / r

🔵 R interpreter for executable documents
Apache License 2.0
15 stars 6 forks source link

Error: 'install' is not an exported object from 'namespace:stencila' #19

Closed RaoOfPhysics closed 6 years ago

RaoOfPhysics commented 7 years ago

Hello,

Thank you for the lovely project. I'm trying to get Stencila to play with R, and I'm a little confused with the documentation. In a few places (e.g. https://github.com/stencila/stencila/wiki/Getting-started and https://github.com/stencila/r#readme), the instructions say I should execute the following as the second step:

stencila:::install()

Notice the three colons! When I enter this command, there is no message at all (error or otherwise). I suspect this is because the commands usually take two colons only?

Now, the file "Stencila Documents" that comes pre-loaded with Stencila, says I should type:

Rscript -e 'stencila::install()'

Notice the two colons! When I execute this, I get the error I posted as the subject, namely:

Error: 'install' is not an exported object from 'namespace:stencila'

I get the same error even when I enter the following, within R:

stencila::install()

Any help on how to proceed will be much appreciated!


System info:

nokome commented 7 years ago

Thanks for trying out Stencila and for the detailed bug report.

stencila:::install() Notice the three colons! When I enter this command, there is no message at all (error or otherwise).

This is the correct syntax and no message is the expected outcome. What install does is to register the Stencila R package by creating a ~/Library/Application Support/Stencila/hosts/r.json (on MacOS) file so that the Stencila Desktop knows can start a new Stencila R session.

But because of some recent changes in the way in which the desktop talks to the R package, you will probably need to start the Stencila R session manually before opening the Desktop:

stencila:::start(authorization=FALSE)

The function name install is confusing (is this package installation?) and it should probably be renamed to register. Thoughts?

I suspect this is because the commands usually take two colons only?

The global Stencila functions install, start, stop etc require three colons because they are not exported by the Stencila namespace. This is intentional (to avoid name clashes with base functions) but confusing because people are used to only two colons. This should probably also be changed.

RaoOfPhysics commented 7 years ago

Thanks for the reply, @nokome. Some thoughts (as a non-developer):

But because of some recent changes in the way in which the desktop talks to the R package, you will probably need to start the Stencila R session manually before opening the Desktop:

stencila:::start(authorization=FALSE)

The function name install is confusing (is this package installation?) and it should probably be renamed to register. Thoughts?

The global Stencila functions install, start, stop etc require three colons because they are not exported by the Stencila namespace. This is intentional (to avoid name clashes with base functions) but confusing because people are used to only two colons. This should probably also be changed.

I hope this helps! Please let me know if you need any further feedback from me. :)

nokome commented 7 years ago

Thanks @RaoOfPhysics - those are all useful suggestions - thanks for taking the time, much appreciated.

arinbasu commented 6 years ago

I too cannot get R to work with stencila. I have done as follows (R 3.5.0, Mac OsX High Sierra 10.13.4)

  1. Installed "stencila/r" via github, then:
  2. stencila:::install() in an R console, returns no error

In stencila desktop (I open this from a cloned repo of stencial "desktop" folder by typing "npm start", I can get the R instance of the code block (i.e., it does not return that Rcontext is not recognised; it for example cannot recognise my python), but it does not execute any R code in the code block. I understand you are still working on R integration as I get to see that when I type

stencila:::start(authorization=FALSE) in an R console, it opens a page at localhost:2000 and says something like "work in progress". Unfortunately, on my Mac

stencila:::register() returns an error. Hope I can use R on stencila soon. /Arindam Basu

nokome commented 6 years ago

Hi @arinbasu : I'm currently working on the R package (it's now the focus for development now the 0.28.0 version of Stencila Desktop is ready) and will push up some changes later today. Perhaps then we could do a chat or video session to resolve any issues you are having.

nokome commented 6 years ago

Oh, and I can resist a screenshot, just to keep you persevering

image

RaoOfPhysics commented 6 years ago

Yay! Glad this is resolved. Will test it (locally and with Binder).

nokome commented 6 years ago

@RaoOfPhysics thanks. Would be great if you could test it out: you'll need to use Stencila Desktop 0.28 binaries available here: https://github.com/stencila/desktop/releases/tag/v0.28.0

arinbasu commented 6 years ago

Hi @nokome I just installed stencial v0.28 using the binary Mac version (Mac Osx 10.13.4) Then I reinstalled stencila/r from the github repo using the R console (i.e., after typing R at command prompt), and then typed:

stencila:::register()

This went without any error message. Closed and restarted stencila. Then clicked to open a code cell and selected R. The status at the code cell did not change instantaneously (it changes instantly if I select mini/javascript/node or if I select python for which I have not installed the contexts, it returns an error message. But for R, it did not return an error message that it did not recognise the context, but it did not execute the code either. Very simple code,

print("Hello World")

I will try next to see if I can reinstall new version of stencila from github repo and try that route. My only complaint there is that, every time I reinstall stencila from github repo, I have to go through the entire process of installing electron (all of it!), and set Python at 2.7, so it's something like:

git clone <repo>
cd stencila/desktop
npm install --python=python2.7

It will run a bunch of codes and then each time I usually have to reinstall electron, :-(, then if I run

npm start

It will open up an electron window and start it. Workaround?

Best, Arin

nokome commented 6 years ago

@arinbasu the best way to debug connection issues between the desktop and an external host is to use the Electron "Devtools" : Ctrl+Shift+I or View > Toogle Developer Tools. Do that when you open the app. That will allow you to see Network requests to the host and any error messages. I'm around in the Gitter channel if you'd like to walkthough debugging the issue.

It will run a bunch of codes and then each time I usually have to reinstall electron

If you just pull the most recent version commit and then do npm install it will only reinstall packages that have been updated e.g.

cd stencila/desktop
git pull
npm install --python=python2.7
npm start

Perhaps you could see if that workd better for you?

RaoOfPhysics commented 6 years ago

Hi @arinbasu, @nokome,

So, I've submitted a PR to fix the command in the stencila/r README (https://github.com/stencila/r/pull/23) and have updated the Wiki (https://github.com/stencila/stencila/wiki/Getting-started).


[EDIT] P.S.: I'm using R v3.5.0.

arinbasu commented 6 years ago

Hi @RaoOfPhysics and @nokome

Thanks a million Nokome and Achintya for your solutions. I uninstalled and removed the git folder I had

sudo rm -rf stencila

Then downloaded the version 0.28 from stencila website and installed as Achintya wrote.

Then in an R console, I did:

devtools::install_github("stencila/r")
stencila:::register()

Things went well (read on). I opened Stencila and was able to see a nice R console working. Yay! Right? So, yes R works (sort of) Here: R works

But,

  1. Stencila does not save any document
  2. I cannot load packages such as I cannot do library(tidyverse) and work with it.

I checked with the devtools part of the electron, and this is what I found:

Why will it not save

OK, so what do I need to do to make sure that Stencila:

  1. Reads r packages
  2. Saves my files to a folder

I do not have this problem with Texture. Texture saves my files to xml format in a specified folder and works as it should. On that note, after removing stencila folder from my home directory, if I then clone the git again and attempt to install, I cannot do this on my macOS using npm/sudo npm due to one or another problem. I troubleshot this on Friday but I am too tired now to go through that process again. I'd rather live with the .dmg and directly install it if that works.

Best, Arin