You only need to run one of those commands to set up environment variables. Looks like you are using BASH so you only need to run the .sh file and not the .csh one.
Thanks for your reply. I know those commands do the same thing but I tried them all just in case the result was different. I only ran the .sh file as you suggested and then tried to run exampleB1 but the same thing is happening. I think it has to do with setting up the variables for the datasets as suggested by bmorgan, but I’m not sure how that is done in macOS.
No, I think this is exactly what I’m missing (setting up the variables and the datasets). The post-install page just puts the table with the variables and gives the steps for setting them up in Windows, but I’m not sure how to set them up in Linux. So my question would be, how did you set the variables for the datasets?
The quoted line is exactly what you type, if you are using the Bash shell. The “.” is actually a special command in Bash, which also has the synonym “source” (I prefer using the latter myself). Then you give it the path to the setup script (geant4.sh) that you want to have sourced.
Sorry, I now understand what you both meant. I successfully ran the command
and there was no problem with that but running B1 still produces the same error. However, I think I understand what the problem is. As @php1ic suspected, the variables are not set for the data sets. I ran
and the variables are in different directories inside /full/path/to/install/dir/share, insted of /usr/local/share/. I’m guessing they need to be in the latter but want to ask before moving them. If that’s correct, should I manually move them there or is there a proper way to do this?
It appears that you ran your CMake build and installation without setting the CMake -DCMAKE_INSTALL_PREFIX=/my/desired/path/to/install/Geant4. The default installation area for CMake is /usr/local.
Therefore, when you source the setup script, presumably you are doing
. /usr/local/bin/geant4.sh
Is that correct? If so, it is setting the data directories to the values you quoted originally, under /usr/local/share
When you configured your Geant4 build, did you set -DGEANT4_INSTALL_DATA=OFF? If you did that, then you explicitly told the build to not download any of the datasets, so of course you don’t have them.
When you configured your Geant4 build, did you set -DGEANT4_INSTALL_DATADIR=/some/other/path/to/the/datasets? If you did that, then the datasets were installed in that other path. But of course, in that case the Geant4 env script should be consistent with that setting.
From what you are saying, maybe I shouldn’t have specified a directory in the -DCMAKE_INSTALL_PREFIX= to have everything installed to the default location /usr/local.
Actually, we’d recommend the opposite. Since G4 is such a huge installation, with so many parts (sources, examples, datasets, etc.), you are generally much better off putting it into a well-defined and separate installation directory tree. On my MacBook, for instance, I have /Applications/GEANT4/, with separate directories under it for each G4 version (all the way from 9.6 up to now!), and I have a directory /Applications/GEANT4/data/ for the datasets from all those releases together.
Ah, ha! I think that may be part of the problem. It sounds like you might have ended up with two separate installations, one under your /path/to/geant4.10.06-install, and one under /usr/local. You may need to do some manual cleaning up of things. I’d recommend in a cleaned out “build” directory, doing one single cmake command with all of the -D options on the same command line.
If you like, there’s also a terminal-based “GUI”, called ccmake, which you can run just giving the source directory path. It pops up a nice terminal menu listing all the possible option settings, and you can step through them with the arrow keys to set the ones you need. I find ccmake very helpful in discovering what settings G4 is using behind the scenes.
I actually set a separate directory for this. I have /Docuements/Geant4/and in Geant4 I have the 3 main directories (the source, build and install directories). I checked in /usr/local and there doesn’t seem to be a Geant4 installation there from what I could find (I checked the bin, include, lib and share directories and the files there are not the ones I see in the installation directory in /Docuements/Geant4/geant4.10.06.p03-install. Do you suggest reinstalling everything? I appreciate your quick responses but I’m uncertain on how to proceed. I still think my issue has to do with the post-install step of setting up the datasets and checking they are correct.
It may be that you would be better off wiping out what you’ve got and doing a clean build and install. In copying and installation of the datasets happens during the build/install process. That process also creates the “geant4.sh” (and .csh) scripts for you, based on the configuration. A clean, consistent build and install should end up with everything in appropriate directories, and with the env scripts pointing to those directories.