Hi,
I’d like to report the following problem (at least in ROOT 5.28, 5.30 and 5.34).
Put any root file as “/tmp/my_file.root”, then “cd” to “/some/working/subdirectory” (should be different from “/tmp”), then try to: import os
import ROOT
print "before cd ... " + os.getcwd() + " ... " + os.getenv("PWD")
os.chdir("/tmp")
print "after cd ... " + os.getcwd() + " ... " + os.getenv("PWD")
root_file = ROOT.TFile("my_file.root", "READ")
print "after ROOT.TFile ... " + os.getcwd() + " ... " + os.getenv("PWD")
root_file.MakeProject("my_lib", "*", "recreate++")
print "after MakeProject ... " + os.getcwd() + " ... " + os.getenv("PWD")
root_file.Close()
print "after Close ... " + os.getcwd() + " ... " + os.getenv("PWD")
What you will get is something like: [code]>>> import os
import ROOT
print “before cd … " + os.getcwd() + " … " + os.getenv(“PWD”)
before cd … /some/working/subdirectory … /some/working/subdirectory
os.chdir(”/tmp")
print "after cd … " + os.getcwd() + " … " + os.getenv(“PWD”)
after cd … /tmp … /some/working/subdirectory
root_file = ROOT.TFile(“my_file.root”, “READ”)
(…)
print "after ROOT.TFile … " + os.getcwd() + " … " + os.getenv(“PWD”)
after ROOT.TFile … /tmp … /some/working/subdirectory
root_file.MakeProject(“my_lib”, “*”, “recreate++”)
MakeProject has generated 41 classes in my_lib
my_lib/MAKEP file has been generated
Shared lib my_lib/my_lib.so has been generated
Error in TUnixSystem::DynamicPathName: my_lib/my_lib.so does not exist in /ROOT/prefix/directory/lib/root:.:/ROOT/prefix/directory/lib/root::/ROOT/prefix/directory/lib/root/cint/cint/stl
print "after MakeProject … " + os.getcwd() + " … " + os.getenv(“PWD”)
after MakeProject … /some/working/subdirectory … /some/working/subdirectory
root_file.Close()
print "after Close … " + os.getcwd() + " … " + os.getenv(“PWD”)
after Close … /some/working/subdirectory … /some/working/subdirectory[/code]
Note what happened … the “MakeProject” properly generated the “/tmp/my_lib/my_lib.so”, but then it unconditionally changed the working directory back to “${PWD}” (which was not “/tmp” but “/some/working/subdirectory”), and so it failed to load the newly created shared library.
What’s even more dangerous … if “MakeProject” finds “my_lib/my_lib.so” somewhere in the “LD_LIBRARY_PATH" (e.g. if some old version "{PWD}/my_lib/my_lib.so” exists), it will load that shared library INSTEAD of the newly created “/tmp/my_lib/my_lib.so”.
Could one, please, fix this behaviour? I believe “MakeProject” should NOT change the working directory at all (it should remain in the same subdirectory in which it was “started”, as the user’s script will probably want to “continue” working there).
For anybody who is affected by this problem … I think I found a “brutal fix”: current_dir = os.getcwd()
root_file.MakeProject(current_dir + "/my_lib", "*", "recreate++")
os.chdir(current_dir)