Install Help for STAN and rstan

382 views
Skip to first unread message

Nathan Lemoine

unread,
Nov 4, 2013, 3:56:44 PM11/4/13
to stan-...@googlegroups.com
Hi,

This might seem like a simple question, but I'm having trouble installing STAN and RStan on my Mac.

For STAN, I followed the directions in the reference manual. I downloaded the source code, unpacked it to a folder in my Applications directory. I've verified that I have the neccessary versions of make and g++. When I navigate to my stan folder, I run

make bin/libstan.a

and I get the error:

make/tests:169: *** multiple target patterns.  Stop.

I've  tried looking this up, but I couldn't find anything.

Second, when I try to install RStan, I followed the directions on the website. I installed Rcpp and inline packages. I verified that I have a C++ compiler (the 'hello world' code worked). But when I try to install RStan, I get the error 

ERROR: failed to lock directory ‘/Users/Nate/Library/R/3.0/library’ for modifying
Try removing ‘/Users/Nate/Library/R/3.0/library/00LOCK-rstan’

There is no folder called 00LOCK-rstan in my directory and if I run 

remove.packages('rstan')

I get an error that there is no package called rstan installed.

What am I doing wrong?

Thanks,

Nate

Bob Carpenter

unread,
Nov 4, 2013, 6:49:25 PM11/4/13
to stan-...@googlegroups.com


On 11/4/13, 3:56 PM, Nathan Lemoine wrote:
> Hi,
>
> This might seem like a simple question, but I'm having trouble installing STAN and RStan on my Mac.

Just a heads up: you don't need command-line Stan in order to run RStan.

You'll need to give us a little more info before
we can help you debug. Which version of Mac OS are
you using and which version of g++ and make (you can type
"g++ -v" and "make -v" in a shell for the latter)?

> For STAN, I followed the directions in the reference manual. I downloaded the source code,

From a GitHub branch or one of our stable distributions? If
the latter, which one? If the former, when?

> unpacked it to a folder in my
> Applications directory. I've verified that I have the neccessary versions of make and g++. When I navigate to my stan
> folder,

You should be able to run "ls" and see the top-level makefile
and src directory if you're in the right location.

I run
>
> make bin/libstan.a
>
> and I get the error:
>
> make/tests:169: *** multiple target patterns. Stop.
>
> I've tried looking this up, but I couldn't find anything.

Basically, all the online info I found just repeats the message.

Have you perhaps modified the makefile? I'd try downloading
it again or unpacking from the tarball you have depending on
how you downloaded it. You shouldn't get this problem if you
don't have a corrupted makefile.

> Second, when I try to install RStan, I followed the directions on the website. I installed Rcpp and inline packages. I
> verified that I have a C++ compiler (the 'hello world' code worked). But when I try to install RStan, I get the error
>
> ERROR: failed to lock directory �/Users/Nate/Library/R/3.0/library� for modifying
> Try removing �/Users/Nate/Library/R/3.0/library/00LOCK-rstan�

I'm not an R expert, but can you search for a file 00LOCK-rstan using
Spotlight and see if you have one anywhere? I don't know what R uses
them for, but files with "LOCK" in the name are typically used for
old-school process-level synchronization. If something dies in the middle
without cleaning up the lock, you basically have problems because you
can't start a process again if there's already a lock file that it's
expecting to create in place.

> There is no folder called 00LOCK-rstan in my directory and if I run
>
> remove.packages('rstan')
>
> I get an error that there is no package called rstan installed.

Right -- you bombed out in the middel of the install. You may need
to find where it partially installed and just clean everything out.

R users tend to just reinstall R from scratch when something like
this goes wrong! But you can probably affect a subtler fix by just
cleaning out the litter from the failed install and trying again.

Make sure you follow the instructions to shut down and restart R
in between installs.

> What am I doing wrong?

Hard to know without more info. I wish we could make this process
easier for users, but R is super stateful, and it can get itself
into a knot like you've found that you can't get out of from within
R itself.

- Bob

Nathan Lemoine

unread,
Nov 4, 2013, 6:52:53 PM11/4/13
to stan-...@googlegroups.com
Thanks for the response. I have looked for the 00LOCK file in spotlight and in hidden files and found nothing.

I did get rstan installed successfully. The issue was, I think, actually really simple. I was running two R consoles, and I had tried to install rstan on one of them. I shut them both down and restarted and it installed fine. It looks like there was an issue with running two consoles at once.
>> ERROR: failed to lock directory ‘/Users/Nate/Library/R/3.0/library’ for modifying
>> Try removing ‘/Users/Nate/Library/R/3.0/library/00LOCK-rstan’
>
> I'm not an R expert, but can you search for a file 00LOCK-rstan using
> Spotlight and see if you have one anywhere? I don't know what R uses
> them for, but files with "LOCK" in the name are typically used for
> old-school process-level synchronization. If something dies in the middle
> without cleaning up the lock, you basically have problems because you
> can't start a process again if there's already a lock file that it's
> expecting to create in place.
>
>> There is no folder called 00LOCK-rstan in my directory and if I run
>>
>> remove.packages('rstan')
>>
>> I get an error that there is no package called rstan installed.
>
> Right -- you bombed out in the middel of the install. You may need
> to find where it partially installed and just clean everything out.
>
> R users tend to just reinstall R from scratch when something like
> this goes wrong! But you can probably affect a subtler fix by just
> cleaning out the litter from the failed install and trying again.
>
> Make sure you follow the instructions to shut down and restart R
> in between installs.
>
>> What am I doing wrong?
>
> Hard to know without more info. I wish we could make this process
> easier for users, but R is super stateful, and it can get itself
> into a knot like you've found that you can't get out of from within
> R itself.
>
> - Bob
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "stan users mailing list" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/LDiz3a8xEiU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Bob Carpenter

unread,
Nov 4, 2013, 6:55:43 PM11/4/13
to stan-...@googlegroups.com
So you still can't get the command-line make version to work?

If that's still the case, can you send me a copy of the makefile
or try again with a fresh copy from the directory in which the
makefile resides?

- Bob
>>> ERROR: failed to lock directory �/Users/Nate/Library/R/3.0/library� for modifying
>>> Try removing �/Users/Nate/Library/R/3.0/library/00LOCK-rstan�
>>

Nathan Lemoine

unread,
Nov 5, 2013, 2:37:48 PM11/5/13
to stan-...@googlegroups.com
I tried with a fresh download and still got the same error when attempting to install the command-line version.

Here's the makefile.

makefile

Bob Carpenter

unread,
Nov 5, 2013, 9:00:09 PM11/5/13
to stan-...@googlegroups.com
Which directory did you unpack Stan into? It looks like
this problem can creep in through template matching if
the path contains a colon (I didn't even know that was
legal in a file name). For instance, it seems a common problem
on Cygwin for Windows when using absolute Windows path names with
colons in them.

Also, which version of make are you using? I get:

$ make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

For what it's worth, nobody else has ever reported a problem like
this :-)

- Bob


On 11/5/13, 2:37 PM, Nathan Lemoine wrote:
> I tried with a fresh download and still got the same error when attempting to install the command-line version.
>
> Here's the makefile.
>
>
>
>
>

Nathan Lemoine

unread,
Nov 5, 2013, 9:32:10 PM11/5/13
to stan-...@googlegroups.com
I get the same make version as you.

I'm trying to unpack into /Applications/stan

Here's the full report:

$ make bin/libstan.a
Loading required package: stats
Loading required package: methods

Attaching package: ‘scales’

The following object is masked from ‘package:plotrix’:

rescale

make/tests:169: *** multiple target patterns. Stop.



>>>>>> ERROR: failed to lock directory ‘/Users/Nate/Library/R/3.0/library’ for modifying
>>>>>> Try removing ‘/Users/Nate/Library/R/3.0/library/00LOCK-rstan’
>>>>>

Bob Carpenter

unread,
Nov 6, 2013, 12:49:00 AM11/6/13
to stan-...@googlegroups.com



On 11/5/13, 9:32 PM, Nathan Lemoine wrote:
> I get the same make version as you.
>
> I'm trying to unpack into /Applications/stan
>
> Here's the full report:
>
> $ make bin/libstan.a
> Loading required package: stats
> Loading required package: methods
>
> Attaching package: �scales�
>
> The following object is masked from �package:plotrix�:
>
> rescale
>
> make/tests:169: *** multiple target patterns. Stop.

This is very confusing. The "Loading required package: stats"
thing looks like it's from R. Command-line Stan has nothing to
do with R. Where is that "$" prompt coming from? Are you running
from an ordinary bash terminal window?

What I get when I unpack into ~/stan-2.0.1/ is:

~/stan-2.0.1$ pwd
/Users/carp/stan-2.0.1

~/stan-2.0.1$ ls -l makefile
-rw-r--r--@ 1 carp staff 7583 Oct 24 14:39 makefile

~/stan-2.0.1$ make bin/libstan.a
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE
-DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256 -c -O3 -o bin/stan/agrad/rev/var_stack.o
src/stan/agrad/rev/var_stack.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE
-DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256 -c -O3 -o bin/stan/math/matrix.o
src/stan/math/matrix.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE
-DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256 -c -O3 -o bin/stan/agrad/matrix.o
src/stan/agrad/matrix.cpp


Maybe you could try moving the Stan to a different location within
your own user space (I'm not much of a sysadmin, just repeating
what works for me).

- Bob

Nathan Lemoine

unread,
Nov 6, 2013, 10:17:31 AM11/6/13
to stan-...@googlegroups.com
I was confused by the R thing as well. I'm using a regular terminal window, and I never open R or invoke it in any way.

I moved stan to my root directory to try it there. Here's my terminal output

Nathans-MacBook-Pro-2:~ Nate$ cd stan-2.0.1
Nathans-MacBook-Pro-2:stan-2.0.1 Nate$ pwd
/Users/Nate/stan-2.0.1
Nathans-MacBook-Pro-2:stan-2.0.1 Nate$ ls -l makefile
-rw-r--r--@ 1 Nate staff 7583 Oct 24 14:39 makefile
Nathans-MacBook-Pro-2:stan-2.0.1 Nate$ make bin/libstan.a
Loading required package: stats
Loading required package: methods

Attaching package: ‘scales’

The following object is masked from ‘package:plotrix’:

rescale

make/tests:169: *** multiple target patterns. Stop.


On Nov 6, 2013, at 12:49 AM, Bob Carpenter <ca...@alias-i.com> wrote:

>
>
>
> On 11/5/13, 9:32 PM, Nathan Lemoine wrote:
>> I get the same make version as you.
>>
>> I'm trying to unpack into /Applications/stan
>>
>> Here's the full report:
>>
>> $ make bin/libstan.a
>> Loading required package: stats
>> Loading required package: methods
>>
>> Attaching package: ‘scales’
>>
>> The following object is masked from ‘package:plotrix’:
>>
>> rescale
>>
>> make/tests:169: *** multiple target patterns. Stop.
>
> This is very confusing. The "Loading required package: stats"
> thing looks like it's from R. Command-line Stan has nothing to
> do with R. Where is that "$" prompt coming from? Are you running
> from an ordinary bash terminal window?
>
> What I get when I unpack into ~/stan-2.0.1/ is:
>
> ~/stan-2.0.1$ pwd
> /Users/carp/stan-2.0.1
>
> ~/stan-2.0.1$ ls -l makefile
> -rw-r--r--@ 1 carp staff 7583 Oct 24 14:39 makefile
>
> ~/stan-2.0.1$ make bin/libstan.a
> g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256 -c -O3 -o bin/stan/agrad/rev/var_stack.o src/stan/agrad/rev/var_stack.cpp
> g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256 -c -O3 -o bin/stan/math/matrix.o src/stan/math/matrix.cpp
> g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256 -c -O3 -o bin/stan/agrad/matrix.o src/stan/agrad/matrix.cpp
>
>
> Maybe you could try moving the Stan to a different location within
> your own user space (I'm not much of a sysadmin, just repeating
> what works for me).
>
> - Bob
>

Daniel Lee

unread,
Nov 6, 2013, 10:58:14 AM11/6/13
to stan-...@googlegroups.com
Nathan,

I have a guess as to what's going on. I'll start with a possible workaround:
  • Try replacing your make/tests with the one attached. It just has lines 131 to 145 commented out.
Please let us know if that works. Sorry about the difficulties -- our builds definitely shouldn't fail in this way.


What I think is happening:
There's a call to Rscript in make/tests used to shuffle tests. My guess is that in your configuration of R, there are some libraries that are automatically loaded. We use that output to generate dependencies: if that has a colon in it, make won't be able to handle it.

Would you mind running this line from the terminal and letting us know the output?
Rscript -e "cat(sample(commandArgs(trailingOnly=TRUE)))" 1 2 3

If that is the cause of the problem, I'll create an issue for it and get it patched asap. I'm moving the technical discussion to the stan-dev mailing list.



Daniel



You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
tests

Nathan Lemoine

unread,
Nov 6, 2013, 11:10:43 AM11/6/13
to stan-...@googlegroups.com
Hi Daniel,

I ran the Rscript command in my terminal and got this:

Nathans-MacBook-Pro-2:~ Nate$ Rscript -e "cat(sample(commandArgs(trailingOnly=TRUE)))" 1 2 3
Loading required package: stats
Loading required package: methods

Attaching package: ‘scales’

The following object is masked from ‘package:plotrix’:

    rescale


Welcome at Wed Nov  6 11:07:12 2013 
Loaded Cairo Package With Correct Fonts
Loaded Lattice
Loaded Plotrix
Loaded ggplot2
2 1 3
Goodbye at  Wed Nov  6 11:07:12 2013 

One thing worth noting is that I have a custom .Rprofile that automatically loads the packages you see there (cairo, lattice, plotrix, and ggplot2) on startup. That might have something to do with it.

I replaced the test makefile with the one you gave me and it appears to have worked:

Nathans-MacBook-Pro-2:stan-2.0.1 Nate$ make bin/libstan.a
i686-apple-darwin11-llvm-g++-4.2: src/stan/model/model_header.hpp: linker input file unused because linking not done
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256   -c -O3 -o bin/stan/agrad/rev/var_stack.o src/stan/agrad/rev/var_stack.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256   -c -O3 -o bin/stan/math/matrix.o src/stan/math/matrix.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -Wno-unused-function -ftemplate-depth-256   -c -O3 -o bin/stan/agrad/matrix.o src/stan/agrad/matrix.cpp
ar -rs bin/libstan.a bin/stan/agrad/rev/var_stack.o bin/stan/math/matrix.o bin/stan/agrad/matrix.o
ar: creating archive bin/libstan.a

Does this help?

Daniel Lee

unread,
Nov 6, 2013, 11:15:27 AM11/6/13
to stan-...@googlegroups.com
Yes, thank you for reporting back. It confirms what I thought was the cause of the issue.

Sorry again for the installation trouble. These are definitely on our build side and we'll try to get it worked out asap.


Daniel



Daniel Lee

unread,
Nov 6, 2013, 11:25:02 AM11/6/13
to stan-...@googlegroups.com
I just created an issue on GitHub: #369.
https://github.com/stan-dev/stan/issues/369

This will be fixed by the next release.



Daniel

Nathan Lemoine

unread,
Nov 6, 2013, 11:25:43 AM11/6/13
to stan-...@googlegroups.com
No worries!

You received this message because you are subscribed to a topic in the Google Groups "stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/LDiz3a8xEiU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.

Ben Goodrich

unread,
Nov 6, 2013, 3:27:32 PM11/6/13
to stan-...@googlegroups.com
You can also work around it using the answer I gave here:

http://stackoverflow.com/questions/16990833/error-instaling-rstan-on-rstudio-server

Ben

Nathan Lemoine

unread,
Nov 7, 2013, 11:02:27 AM11/7/13
to stan-...@googlegroups.com
For what it's worth, I suspect this problem hasn't come up much because most people with custom R profiles are heavy R users and probably installed Rstan (which works fine for me).

The only reason I even found out this was a problem was because I didn't understand that Rstan was completely self-contained. I thought it was similar to Rjags, where I needed a base install of Stan that Rstan calls from R. If I had known what I was doing, I probably wouldn't have bothered with the command line version and never would have encountered the problem.
Reply all
Reply to author
Forward
0 new messages