Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manualy Set R_HOME Cause Error in loading DLL...etc #6

Open
crystalxp opened this issue Jan 3, 2017 · 3 comments
Open

Manualy Set R_HOME Cause Error in loading DLL...etc #6

crystalxp opened this issue Jan 3, 2017 · 3 comments

Comments

@crystalxp
Copy link

crystalxp commented Jan 3, 2017

Thanks for your good library...this lib is very cool.
i want to report some bugs(maybe?...)
When Manualy Set R_HOME in Windows setting , then program can't load dll successful...

and I think use {$IFDEF Win64} in lib better than {$IFNDEF CPUX64} and TOSVersion.Architecture to get right r.dll for app (win32 app load x32 dll, and win64 app load x64 dll)

@rlsdevine
Copy link
Contributor

Thanks for your feedback - I'm hoping to get back onto this in a few weeks and will take a look at your report.

@crystalxp
Copy link
Author

crystalxp commented Jan 10, 2017

helllo,I finally find why this bug happend:
because of the .FindRPaths has a logical bug:

the fixed function is below:

// ------------------------------------------------------------------------------
class procedure TNativeUtility.FindRPaths(var path: string; var homeDir: string;
logger: TStringList);
var
printPath: string;
printHome: string;
begin
if path = '' then
printPath := 'null'
else
printPath := path;
if homeDir = '' then
printHome := 'null'
else
printHome := homeDir;
logger.Add(Format('Caller provided path = "%s", homeDir = "%s"',
[printPath, printHome]));

if homeDir = '' then
begin
homeDir := GetEnvironmentVariable('R_HOME');
if homeDir = '' then
printHome := 'null'
else
printHome := homeDir;
logger.Add(Format('opaR looked for preset R_HOME env. var. and found: "%s"',
[printHome]));
end;

if homeDir = '' then
begin
homeDir := FindRHome(path, logger);
if homeDir = '' then
printHome := 'null'
else
printHome := homeDir;
logger.Add
(Format('opaR looked for platform-specific way (e.g. win registry) and found: "%s"',
[printHome]));
end;

if homeDir = '' then
logger.Add
('Error: R_HOME was not provided and a suitable path could not be found by opaR');

if not(homeDir = '') then
begin
if path = '' then
begin
path := FindRPath(homeDir);
if path = '' then
printPath := 'null'
else
printPath := path;
logger.Add
(Format('opaR trying to find rPath based on rHome; Deduced: "%s"',
[printPath]));
end;

if path = '' then
begin
  path := FindRPath;
  if path = '' then
    printPath := 'null'
  else
    printPath := path;
  logger.Add
    (Format('opaR trying to find rPath independently of rHome; Deduced: "%s"',
    [printPath]));
end;

end
else
begin
homeDir := FindRHome(path);
if homeDir = '' then
printHome := 'null'
else
printHome := homeDir;
logger.Add(Format('opaR trying to find rHome based on rPath; Deduced: "%s"',
[printHome]));
end;
end;

@crystalxp
Copy link
Author

and I find another bug in win64 app when excute some case, and i post that bug as another issue. please check it , thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants