[ESS] cannot add bindings to a locked environment

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

More experiments.  First, I tried including the file contents without loading the library. ESS seems to have detected and loaded the library anyway:
 Loading required package: Matrix # LazarSim depends on Matrix
 [1] "test"
 [1] "shortName"
 [1] "shortName"
 [1] "test"
 [LazarSim] Sourced file /home/ross/Lazar/LazarSim/R/Test.R
 > search() # shows LazarSim loaded
  [1] ".GlobalEnv"        "package:LazarSim"  "package:Matrix"
  [4] "ESSR"              "package:stats"     "package:graphics"
  [7] "package:grDevices" "package:utils"     "package:datasets"
 [10] "package:methods"   "Autoloads"         "package:base"
 > sb <- StandBonf(alpha=0.1)
 > class(sb)
 [1] "StandBonf"
 [1] "LazarSim" # and the definition is in the package
!> shortName(sb)
 Error in assign(".SigLength", nsig, envir = env) (from Test.R#13) :                                                
   cannot add bindings to a locked environment
Additionally, while typing "short" for the last line the echo area displayed

Company: Back-end (company-R-args company-R-objects :separate) error "Symbol's function definition is void: :separate" with args (ignore-case)

Second try, disabling namespace binding (not sure that's the right term) in emacs, i.e., C-c C-t C-s
The first time I typed that sequence it offered a llist with LazarSim first (even though I restarted R).  I hit enter and got a message "Using namespace LazarSim".  Did C-c C-t C-s again; this time None was the first choice.  I hit enter.  As added protection I tried C-c C-r to read in the file.  LazarSim still ended up loaded.

Third try: copy the file with the test code to a directory that is not part of the package.  Finally I'm able to read the file in without loading the package, and everything works OK:
 > getwd()  # the package is in the LazarSim subdirectory of the working dir
 [1] "/home/ross/Lazar"
 > include("Test.R")  #I guess I meant source()
 Error: could not find function "include"
 > #visited file in emacs and did C-c C-l
 [1] "test"
 [1] "shortName"
 [1] "shortName"
 [1] "test"
 Sourced file /home/ross/Lazar/Test.R
 > search() #no LazarSim
  [1] ".GlobalEnv"        "ESSR"              "package:stats"
  [4] "package:graphics"  "package:grDevices" "package:utils"
  [7] "package:datasets"  "package:methods"   "Autoloads"
 [10] "package:base"
 > sb <- StandBonf(alpha=0.1)
 > class(sb)
 [1] "StandBonf"
 [1] ".GlobalEnv" # Yea
 > shortName(sb)
 [1] "StandBonf"

More information about the ESS-help mailing list