What we want to do is find the users home directory.
Your
On 1/20/14, 12:47 AM, Andrew Gelman wrote:
> Bob:
>
> 1. I suspect this will work for windows and linux users too, assuming the file always has that name.
Unfortnateky, Windows is a whole different beast.
There is no "~/." on Windows --- those instructions are
for Mac OS X Mavericks only! Mac's Xcode set the max template
depth too low, so we've had to code around it.
> To put it another
> way, I'd guess that if these new instructions _don't_ work with someone's install, then the existing instructions (which
> specify to find this file in that certain place) won't work either. So if there might be a problem, in any case we
> would need a sentence in the instructions saying something like: If these instructions don't work, you'll have to
> search for Makevars, which for some reason might not be in the usual place ~/.R/Makevars
We could do that. As I said in a previous post, our instructions
are already so qualified that I'm reluctant to make them even
deeper without (a) breaking the instructions apart per platform,
and (b) creating a checklist.
> I think Jiqiang or Ben will have to answer whether this could ever occur.
> My guess is that R has some direct way of accessing the location of its Makevars file (e.g., a function called
> getMakevars()) or something like that.
No that I could find, but it has a way of accessing a home environment, which
I mentioned before, and the ".R" directory should be under the
user's home directory. That Makevars file might not even exist, so searching
for it's not going to help. The instructions are of the variety "if you do
have such a Makevars and it has the wrong thing in it, you need to fix it".
> This would seem to me to be more robust than hard-coding "~/.R/Makevars". But,
> again, the current instructions hard-code it already, so I can't see my new instructions causing problems that weren't
> already there.
I'm with you there.
> 2. In answer to your second question, we can just send them this R code:
>
> if (!file.exists ("~/.R/Makevars")) cat ('CXX=g++ -arch x86_64 -ftemplate-depth-256
> -stdlib=libstdc++\nCXXFLAGS="-mtune=native -O3 -Wall -pedantic -Wconversion"\n', file="~/.R/Makevars")
>
> Of course, that just raises the question of why not put this R code on the website in the first place? Or, maybe better
> still, 2 lines of R code, where the first line searches for the Makevars file and, if it exists, saves it with some name
> such as Makevars_old_current_date, and the second line is what I have above. Then we add a note in the website saying
> that, if there was anything important in the old Makevars file, you can find it at ~/.R/Makevars_old_current_date
>
> This will satisfy the needs of Andrew-syle users while also following a no-destroy policy and making everything
> accessible to the sophisticates.
As Ben pointed out, it may break other packages that won't compile
at -O3. But we can let the other packages sort that out --- Ben just
said we should bring bodyguards to conferences :-)
So, I did as you asked and added this to the instructions:
One way you can achieve this is to execute this from within R:
if (!file.exists("~/.R/Makevars")) {
cat('CXX=g++ -arch x86_64 -ftemplate-depth-256 -stdlib=libstdc++\n
CXXFLAGS="-mtune=native -O3 -Wall -pedantic -Wconversion"\n',
file="~/.R/Makevars");
} else {
file.show("~/.R/Makevars");
}
If the Makevars file already exists, its content will be displayed and you
can decide whether to run the cat part of the above command and destroy the
existing Makevars file.
What a huge pain!
> All this of course will be superseded by our eventual one-click install�
Feel free to go edit the Wiki instructions to your liking --- you should
have permission if you're logged into GitHub:
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
- Bob