[ESS] cannot add bindings to a locked environment

Boylan, Ross Ro@@@Boy|@n @end|ng |rom uc@|@edu
Mon Jul 25 02:21:52 CEST 2016


The package isn't public yet.  But I don't think it matters, beyond providing a namespace, since the file with the new code, which was in my earlier post, has names that aren't otherwise in the package.

So how does ESS decide which package namespace to use, absent explicit instructions?  There are two mechanisms that fit the behavior I saw
1) Use the first package on the search list.  Since I did library(LazarSim), it was at the front of the list.
2) Infer the package from the location of the file I did C-c C-l.  There's a potential risk to this, since the code in that source tree is not necessarily the code in the library picked up in the library() statement, even though both are named LazarSim.

It sounds as if deactivating the namespace will get me the behavior I was expecting.

But I'm puzzled by the problem I ran into.  Ordinarily I would want to make changes in the  package's namespace, but if my attempts to change produce a "cannot add bindings" error then I can't make changes (at at least I can't add new symbols).

I just did a git pull/make/ restart emacs.  But I get the same behavior:
---------------------------------------------
> library(LazarSim)
 Loading required package: Matrix
 > 
 [1] "test"
 [1] "shortName"
 [1] "shortName"
 [1] "test"
 [LazarSim] Sourced file /home/ross/Lazar/LazarSim/R/Test.R
 > sb <- StandBonf(alpha=0.1)
 > class(sb)
 [1] "StandBonf"
 attr(,"package")
 [1] "LazarSim"
!> shortName(sb)
 Error in assign(".SigLength", nsig, envir = env) (from Test.R#13) :                                                
   cannot add bindings to a locked environment
------------------------------------------------------

Here's some version info on ESS, first the version I was running and then the version after the pull:
----------------------------------------------------
ross using ross-node1:~/ESS$ git branch
* master
ross using ross-node1:~/ESS$ git remote -v
origin  https://github.com/emacs-ess/ESS.git (fetch)
origin  https://github.com/emacs-ess/ESS.git (push)
ross using ross-node1:~/ESS$ git log -2
commit 2130dda2f8bb56e603c9a823b0d754e1a4444080
Author: Martin Maechler <maechler using r-project.org>
Date:   Tue May 24 19:07:16 2016 +0200

    "cosmetic" (nonused, deprecated)

commit 8dc7f55a5233ed53ea0f1cc7ed50686955be5e38
Author: Vitalie Spinu <spinuvit using gmail.com>
Date:   Wed May 25 12:59:55 2016 +0200

    Set ess-can-eval-in-background to t and remove async evaluation for now
ross using ross-node1:~/ESS$ git rev-parse origin/master
e4eda78d05f91e68d8dd7007bbff3422cd653c6b
ross using ross-node1:~/ESS$ git rev-parse master
2130dda2f8bb56e603c9a823b0d754e1a4444080
ross using ross-node1:~/ESS$ date; git pull
Sun Jul 24 17:00:16 PDT 2016
# ......
ross using ross-node1:~/ESS$ git rev-parse master
5141f425e60cb202e5f6d42b7eb260288da66071
ross using ross-node1:~/ESS$ git rev-parse origin/master
5141f425e60cb202e5f6d42b7eb260288da66071
ross using ross-node1:~/ESS$ git branches
git: 'branches' is not a git command. See 'git --help'.
ross using ross-node1:~/ESS$ git branch -v
* master 5141f42 Fix manual entry for new namespaced evaluation
ross using ross-node1:~/ESS$ git -log -2
*** output flushed ***
ross using ross-node1:~/ESS$ git log -2
commit 5141f425e60cb202e5f6d42b7eb260288da66071
Author: Vitalie Spinu <spinuvit using gmail.com>
Date:   Sat Jul 23 22:56:02 2016 +0200

    Fix manual entry for new namespaced evaluation

commit e0e316386040a93c87b5f8ed32176ace1b39f4b1
Author: Vitalie Spinu <spinuvit using gmail.com>
Date:   Thu Jul 21 12:13:24 2016 +0200

    Change :sorted to new :separate in R company backends
ross using ross-node1:~/ESS$ date; make
# etc
------------------------------------------------------------------------

New content ends here.
Ross
________________________________________
From: Vitalie Spinu [spinuvit using gmail.com]
Sent: Saturday, July 23, 2016 2:20 PM
To: Boylan, Ross
Cc: ess-help using r-project.org
Subject: Re: [ESS] cannot add bindings to a locked environment

>> On Sat, Jul 23 2016 05:09, Boylan, Ross wrote:

> The reason I was trying to set the environment was to get around the following problem.  I was going to  post this to the R list, but after debugging it I suspect it may be ess-related, and so I'm posting it here.

> Sequence
> 1. start R 3.1 via ESS 16.04 in Emacs 24.4
> 2.in R, do library(LazarSim)

Is this package public somewhere? I would like to try to reproduce if possible.

> Debugging that error showed the env in the error message was <environment: namespace:LazarSim>

> I expected that the file contents of step 3 would end up in the global
> namespace,

No. The code by default ends in the package namespace. You don't need to set
anything. You should be able to deactivate the namespaced evaluation with C-c
C-t C-s. This is primary use of this command right now. There is no C-c C-t C-a
anymore.

> Here's the file for step 3, minus comments
> setClass("AbstractTest", representation=representation(alpha="numeric"))

> setGeneric("test", function(self, r, ...) standardGeneric("test"))

> setGeneric("shortName", function(self) standardGeneric("shortName"))
> setMethod("shortName", c("AbstractTest"),
>           function(self) c(class(self)))

> StandBonf <- setClass("StandBonf", contains="AbstractTest")
> setMethod("test", c("StandBonf"),
>           function(self, r, ...) covariates(bonf(r$all, alpha=self using alpha)))


Works just as expected for me. Would it be possible for you to install the
development version of ESS?

  Vitalie




More information about the ESS-help mailing list