Error: C stack usage is too close to the limit at R startup
Your user .Rprofile
file is loading itself recursively for some reason:
if (file.exists("~/.Rprofile")) {
base::sys.source("~/.Rprofile", envir = environment())
}
From your comments it seems that these lines are inside ~/.Rprofile
(~
expands to the user home directory, i.e. /Users/mycomputer
in your case, assuming mycomputer
is your user name).
Delete these lines (or comment them out), they don’t belong here. In fact, the file looks like it’s a template for a project-specific .Rprofile
configuration. It would make sense inside a project directory, but not as the profile-wide user .Rprofile
.
The logic for these files is as follows:
- If there is an
.Rprofile
file in the current directory, R attempts to load that. - Otherwise, if the environment variable
R_PROFILE_USER
is set to the path of a file, R attempts to load this file. - Otherwise, if the file
~/.Rprofile
exists, R attempts to load that.
Now, this implies that ~/.Rprofile
is not loaded automatically if a projects-specific (= in the current working directory) .Rprofile
exists. This is unfortunate, therefore many projects add lines similar to the above to their project-specific .Rprofile
files to cause the user-wide ~/.Rprofile
to be loaded as well. However, the above implementation ignores the R_PROFILE_USER
environment variable. A better implementation would therefore look as follows:
rprofile = Sys.getenv('R_PROFILE_USER', '~/.Rprofile')
if (file.exists(rprofile)) {
base::sys.source(rprofile, envir = environment())
}
rm(rprofile)
C stack usage 7970960 is too close to the limit
You almost certainly have a bogus function called exp
in your search path somewhere, which calls itself. It may be in your workspace (global environment), or (less likely but possible) in a package you have loaded. (It's also possible that the infinite recursion is defined in a more complicated way, i.e. rather than exp()
calling itself, it calls something that calls it back ...)
The normal, expected result of find("exp")
is
[1] "package:base"
Suppose you have defined a recursive exp
function in your workspace:
exp <- function(x) exp(x)
Then exp(1)
will give
Error: C stack usage 7969716 is too close to the limit
and find("exp")
will give
[1] ".GlobalEnv" "package:base"
i.e. there is an exp
in the global environment that R will see before it sees the built-in function in the base
package.
If you do have something like this going on, starting a new R session will help (unless the object is in a saved workspace that gets restored when the session starts), or rm("exp")
.
GenomicRanges: C stack usage ... is too close to the limit
It turned out to be due to some outdated packages. I did not notice that they were not updated because RStudio's 'update packages functionality' ignores packages one does not have write permission to (thus not informing you they are outdated at all). Thus, it turned out to be due a subtle permissions problem see. See this answer.
Error: C stack usage 15924224 is too close to the limit?
runApp(".")
would source Shiny app files under the current app folder. It searches files named app.R
or ui.R
/server.R
combined. If you have code runApp(".")
in your file, following recursion will happen:
runApp -> source app.R -> find runApp()
in code ->
execute runApp
-> source app.R -> -> find runApp()
in code ->
execute runApp
-> ...
One guideline is to never write runApp
in your app.R
. This function is only to be used on the console. Usually Shiny would return an error and prevent you to be trapped in the loop. Not sure why the error message is not given in your case.
Related Topics
Ggplot2 Ggsave Function Causes Graphics Device to Not Display Plots
Extracting "((Adj|Noun)+|((Adj|Noun)(Noun-Prep))(Adj|Noun))Noun" from Text (Justeson & Katz, 1995)
Select List Element Programmatically Using Name Stored as String
How to Append R Data Frame into Existing Excel Without Overwriting
How to Add Row to Stargazer Table to Indicate Use of Fixed Effects
Find Second Highest Value on a Raster Stack in R
Order Dataframe for Given Columns
How to Plot Multiple Lines in R
R: Check If Value from Dataframe Is Within Range Other Dataframe
Extract Only Folder Name Right Before Filename from Full Path
How to Force Ggplot's Geom_Tile to Fill Every Facet
Tidyeval with List of Column Names in a Function
Change Position of Tick Marks of a Single Graph, Using Ggplot2
R - Carry Last Observation Forward N Times
How to Find The Indices Where There Are N Consecutive Zeroes in a Row
Conda Build R Package Fails at C Compiler Issue on Macos Mojave