If i am not mistaken you cannot really edit the environment variables.
When loading your script ruby loads all the currently known environment variables and adds the values to ENV
.
When editing it, it will only be changed temporarily for the current execution.
If you want to change it and want it to persist you will have to e.g. use system
system("export PATH=$PATH:YOUR_PATH")
Same as you would do it in the CLI