Today I stumbled upon a little problem that first surprised me a little, but thinking about it for another 3 seconds is completely logical. If you start your Images using environments, they are child processes of the Environments process. This is not obvious at first, because you can always close Environments and the image will run on without any problems.
But the images started from Environments inherit the System environment of the Environments process (sorry for the confusion, they are both called environments. I’ll write the VAST Environments program with a capital E in this post to make things easier).
So here is why I am writing about it: I am updating our Kontolino software to use a newer version of some third party library (ERiC, to be exact), and therefor I had to change the PATH variable in Windows, so that VAST accesses the newer version of the DLL.
So I updated the PATH variable and closed my Smalltalk Image in order to restart it and access the new DLLs. My first attempts all crashed, although I thought everything was good with my code. Of course it had to be my code, because I had changed to moving pieces: new DLLs and my calling code in Smalltalk. Since it had to be my fault, the first thing I did was check lots of bits and pieces in my Smalltalk code.
Until I tried executing calls in the old format and got confused a little. Why would old calls run and new ones fail?
There was only one possible explanation: I was obviously using the old DLL.
And it turned out that
returned the old PATH variable. I double-checked in the Windows System setup that the new PATH was set.
Then it suddenly occurred to me: You have to restart Environments to see the new environment (notice the capital E?).
As I said: thinking about this logically makes this post so pointless: of course you have to restart Environments because it starts the Image with its own view of the System that it had when it started. You may think: stupid Joachim! And of course I did as well. But I bet other people can step into this trap very easily as I did, and taking 3 minutes to read this post and shaking your head about my stupidity will probably save you 30 minutes of searching for a problem at the wrong place. And Bang, my post is not so pointless any more 😉
If you want to try yourself what I am talking about, here is how to reproduce it:
- Start Environments
- Start a Smalltalk image from it and keep Environments open (I always do because I sometimes have several images open)
- Go to the Windows Control Panel and change an environment variable, maybe PATH
- Evaluate ‘PATH’ abtScanEnv in your image
- Quit that image and restart it from your running instance of Environments
- Evaluate ‘PATH’ abtScanEnv in your image –> still the old value
- Close Image and Environments
- Start Environments
- Start your image
- Evaluate ‘PATH’ abtScanEnv in your image –> new value