SynthDef BufferPlay fail on Environment Proxy

Good morning;
I am trying to implement in my Setup document for my Live Coding sessions, the following code, to be able to manage the channels of an audio in a SynthDef PlayBuf dynamically:

(

~bufplayerfunc = {|numchans=1|
   {|rate=1, buffer, trigger=1, start=0, loop=0, amp=1, out=0|

      // Buffer player
      var sig = PlayBuf.ar(
         numchans, // Number of channels passed into the function from the outer function
         buffer,
         rate * BufRateScale.kr(buffer),
         trigger,
         start * BufDur.kr(buffer),
         loop
         );

      // Output
      Out.ar(out, sig * amp);
   }
};

(1..64).do{|chanNum|
   var name = "bufplayer" ++ chanNum;
   SynthDef.new(name, ~bufplayerfunc.value(chanNum)).add;
};

)

In a local noproxy environment it works fine, but not in a ProxySpace which returns :

ERROR: Message 'def' not understood.
Perhaps you misspelled 'ref', or meant to call 'def' on another receiver?
RECEIVER:
Instance of NodeProxy {    (0x139b704f8, gc=E4, fmt=00, flg=00, set=04)
  instance variables [16]
    server : instance of Server (0x1083b7288, size=31, set=5)
    bus : nil
    monitor : nil
    parentGroup : nil
    busArg : nil
    busLoaded : false
    reshaping : nil
    group : nil
    objects : instance of Order (0x139cab558, size=2, set=2)
    nodeMap : instance of ProxyNodeMap (0x120969a18, size=9, set=4)
    children : nil
    loaded : false
    awake : true
    paused : false
    clock : instance of TempoBusClock (0x1209e5438, size=8, set=3)
    quant : Integer 4
}
ARGS:
PATH: /Users/sdcarr/Desktop/My-setup-sc-live-coding/Setup/synthdefs.scd

PROTECTED CALL STACK:
	Meta_MethodError:new	0x1088340c0
		arg this = DoesNotUnderstandError
		arg what = nil
		arg receiver = NodeProxy.nil(localhost, nil)
	Meta_DoesNotUnderstandError:new	0x108836380
		arg this = DoesNotUnderstandError
		arg receiver = NodeProxy.nil(localhost, nil)
		arg selector = def
		arg args = [  ]
	Object:doesNotUnderstand	0x120502200
		arg this = NodeProxy.nil(localhost, nil)
		arg selector = def
		arg args = nil
	SynthDef:addControlsFromArgsOfFunc	0x13964ce00
		arg this = SynthDef:bufplayer1
		arg func = NodeProxy.nil(localhost, nil)
		arg rates = nil
		arg skipArgs = 0
		var def = nil
		var names = nil
		var values = nil
		var argNames = nil
		var specs = nil
	SynthDef:buildUgenGraph	0x13964c880
		arg this = SynthDef:bufplayer1
		arg func = NodeProxy.nil(localhost, nil)
		arg rates = nil
		arg prependArgs = [  ]
		var result = nil
		var saveControlNames = nil
	a FunctionDef	0x13964ae00
		sourceCode = "<an open Function>"
	Function:prTry	0x108b8d3c0
		arg this = a Function
		var result = nil
		var thread = a Thread
		var next = nil
		var wasInProtectedFunc = false
	
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	Nil:handleError
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
	Object:throw
		arg this = <instance of DoesNotUnderstandError>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of DoesNotUnderstandError>
	SynthDef:build
		arg this = <instance of SynthDef>
		arg ugenGraphFunc = <instance of NodeProxy>
		arg rates = nil
		arg prependArgs = nil
	< closed FunctionDef >
		arg chanNum = 1
		var name = "bufplayer1"
	Number:forSeries
		arg this = 1
		arg second = 1
		arg last = 64
		arg function = <instance of Function>
		var step = 1
		var j = 0
	Interpreter:interpretPrintCmdLine
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "(1..64).do{|chanNum|
   var ..."
		var doc = nil
		var ideClass = <instance of Meta_ScIDE>
	Process:interpretPrintCmdLine
		arg this = <instance of Main>
^^ ERROR: Message 'def' not understood.
Perhaps you misspelled 'ref', or meant to call 'def' on another receiver?
RECEIVER: NodeProxy.nil(localhost, nil)

Where would the problem lie?
Thanks

When a ProxySpace has been pushed, then everything you put into an ~environmentVariable will be turned into a NodeProxy.

You cannot use environment variables for any data storage in a ProxySpace. This case is no different from buffers.

hjh