Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
facf23de
Commit
facf23de
authored
8 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
use FastR-unique file when validating R_HOME
parent
508f0d0e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java
+19
-7
19 additions, 7 deletions
....r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java
with
19 additions
and
7 deletions
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java
+
19
−
7
View file @
facf23de
...
...
@@ -68,8 +68,7 @@ public final class REnvVars implements RContext.ContextState {
envVars
.
put
(
"R_SHARE_DIR"
,
fileSystem
.
getPath
(
rHome
,
"share"
).
toString
());
String
rLibsUserProperty
=
envVars
.
get
(
"R_LIBS_USER"
);
if
(
rLibsUserProperty
==
null
)
{
String
os
=
System
.
getProperty
(
"os.name"
);
if
(
os
.
contains
(
"Mac OS"
))
{
if
(
isMacOS
())
{
rLibsUserProperty
=
"~/Library/R/%v/library"
;
}
else
{
rLibsUserProperty
=
"~/R/%p-library/%v"
;
...
...
@@ -140,6 +139,11 @@ public final class REnvVars implements RContext.ContextState {
return
val
!=
null
?
val
:
envVars
.
get
(
var
.
toUpperCase
());
}
private
static
boolean
isMacOS
()
{
String
os
=
System
.
getProperty
(
"os.name"
);
return
os
.
contains
(
"Mac OS"
);
}
private
static
final
String
R_HOME
=
"R_HOME"
;
/**
...
...
@@ -147,6 +151,13 @@ public final class REnvVars implements RContext.ContextState {
*/
private
static
String
rHome
;
/**
* Returns a file that only exists in a FastR {@code R_HOME}.
*/
private
static
String
markerFile
()
{
return
"libjniboot."
+
(
isMacOS
()
?
"dylib"
:
"so"
);
}
/**
* Returns the value of the {@code R_HOME} environment variable (setting it in the unusual case
* where it it is not set by the initiating shell scripts. This is called very early in the
...
...
@@ -162,7 +173,7 @@ public final class REnvVars implements RContext.ContextState {
}
else
{
rHomePath
=
Paths
.
get
(
rHome
);
}
if
(!
validateRHome
(
rHomePath
))
{
if
(!
validateRHome
(
rHomePath
,
markerFile
()
))
{
Utils
.
rSuicide
(
"R_HOME is not set correctly"
);
}
rHome
=
rHomePath
.
toString
();
...
...
@@ -181,8 +192,9 @@ public final class REnvVars implements RContext.ContextState {
*/
private
static
Path
getRHomePath
()
{
Path
path
=
Paths
.
get
(
REnvVars
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
()).
getParent
();
String
markerFile
=
markerFile
();
while
(
path
!=
null
)
{
if
(
validateRHome
(
path
))
{
if
(
validateRHome
(
path
,
markerFile
))
{
return
path
;
}
path
=
path
.
getParent
();
...
...
@@ -193,12 +205,12 @@ public final class REnvVars implements RContext.ContextState {
/**
* Sanity check on the expected structure of an {@code R_HOME}.
*/
private
static
boolean
validateRHome
(
Path
path
)
{
private
static
boolean
validateRHome
(
Path
path
,
String
markerFile
)
{
if
(
path
==
null
)
{
return
false
;
}
Path
bin
=
path
.
resolve
(
"
bin
"
);
return
Files
.
exists
(
bin
)
&&
Files
.
isDirectory
(
bin
)
&&
Files
.
exists
(
bin
.
resolve
(
"R"
));
Path
lib
=
path
.
resolve
(
"
lib
"
);
return
Files
.
exists
(
lib
)
&&
Files
.
isDirectory
(
lib
)
&&
Files
.
exists
(
lib
.
resolve
(
markerFile
));
}
private
void
checkRHome
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment