R cannot be initialized - MacOS 10.15.5 - KNIME 4.1.3

Hello Everyone,

I am currently not able to run R Snippets with the following error and I am not sure how to solve it.
Please let me know if you have any suggestions/ideas how to resolve the issue.

R cannot be initialized.
XQuartz is required for the Cairo library on MacOS. Please download and install XQuartz from http://www.xquartz.org/.

KNIME log:

2020-07-17 13:00:24,094 : ERROR : KNIME-Worker-4-R Source (Workspace) 0:248 : : Node : R Source (Workspace) : 0:248 : Execute failed: XQuartz is required for the Cairo library on MacOS. Please download and install XQuartz from http://www.xquartz.org/.
org.knime.r.controller.IRController$RException: XQuartz is required for the Cairo library on MacOS. Please download and install XQuartz from http://www.xquartz.org/.
at org.knime.r.controller.RController.checkCairoOnMac(RController.java:406)
at org.knime.r.controller.RController.initR(RController.java:329)
at org.knime.r.controller.RController.initialize(RController.java:195)
at org.knime.r.controller.RController.(RController.java:167)
at org.knime.r.RSnippetNodeModel.executeInternal(RSnippetNodeModel.java:145)
at org.knime.r.RSnippetNodeModel.execute(RSnippetNodeModel.java:136)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:571)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1236)
at org.knime.core.node.Node.execute(Node.java:1016)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:557)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:218)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:124)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:334)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:210)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)

R scripting extension is installed:

KNIME R Scripting extension 4.0.0.v201906200740 de.mpicbg.tds.knime.scripting.r.feature.feature.group Max Planck Institute of Molecular Cell Biology and Genetics (MPI-CBG), Dresden, Germany

I tested with R 3.6.1 and later upgraded to R 4.0.2:

Path: /Library/Frameworks/R.framework/Resources
or
Path: /Library/Frameworks/R.framework/Versions/4.0/Resources

Rserve and Cairo are installed:

library(Rserve)
library(Cairo)
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] Cairo_1.5-13 Rserve_1.8-7

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2

XQuartz is installed:

XQuartz 2.7.11 (xorg-server 1.18.4)
/opt/X11/bin/xquartz

MacOS 10.15.5
KNIME 4.1.3

Hi there @oliveralka,

welcome to KNIME Community!

Have you checked this R Installation guide?
https://docs.knime.com/2020-07/r_installation_guide/index.html

And this topic can help as well:

Br,
Ivan

1 Like

Hi Ivan,

I went over the topics already and also did a test with installing the packages via your script:
https://bitbucket.org/KNIME/knime-r/src/master/org.knime.r/scripts/

Unfortunately, that did not solve the issue.

Rserve and Cairo seem to work without any issue when called in R directly, but somehow in
KNIME XQuartz is not recognized.

The path to R.home is set as “/Library/Frameworks/R.framework/Versions/4.0/Resources”, which should be fine.

Any ideas on how to narrow down the error?

It seems that KNIME is checking the kMDItemVersion using mdls.

I downloaded and installed the current XQuartz 2.7.11 from https://www.xquartz.org/, but it seems that no kMDItemVersion is available.

user@MBP Utilities % pwd
/Applications/Utilities
user@MBP Utilities % mdls XQuartz.app 
kMDItemFSContentChangeDate = 2020-07-17 08:17:51 +0000
kMDItemFSCreationDate      = 2016-09-26 07:41:50 +0000
kMDItemFSCreatorCode       = ""
kMDItemFSFinderFlags       = 0
kMDItemFSHasCustomIcon     = 0
kMDItemFSInvisible         = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery      = 0
kMDItemFSLabel             = 0
kMDItemFSName              = "XQuartz.app"
kMDItemFSNodeCount         = 1
kMDItemFSOwnerGroupID      = 0
kMDItemFSOwnerUserID       = 0
kMDItemFSSize              = 1
kMDItemFSTypeCode          = ""
user@MBP Utilities % mdls -name kMDItemVersion XQuartz.app 
kMDItemVersion = (null)

Which leads to the described issue above.

I am actually not sure why this happens, since the right version seem to be annotated in the bundle:

user@MBP Utilities % plutil -p /Applications/Utilities/XQuartz.app/Contents/Info.plist | grep CFBundleShortVersionString 

  "CFBundleShortVersionString" => "2.7.11

Edit:
Currently I think this is a specific issue on my system, since it works for other macOS 10.15.5 - I will take a look and post an update here.

Interesting. Have you tried an older version of Xquartz? Maybe you could try to install the same version someone who can use those nodes has installed?

I would really much appreciated if you could keep us posted about your findings.

Best
Mark

I have not found a fix yet - but it does not seem to be an XQuartz or KNIME issue but is related to a faulty Spotlight Index on MacOS.

Checking the available metadata stored in the XQuartz app directory give the expected results:

user@MBP ~ % mdimport -t -d 3 /Applications/Utilities/XQuartz.app
Imported ‘/Applications/Utilities/XQuartz.app’ of type ‘com.apple.application-bundle’ with plugIn /System/Library/Spotlight/Application.mdimporter.
31 attributes returned
{
“:MD:DeviceId” = 16777220;
“:MD:kMDItemPath” = “/Applications/Utilities/XQuartz.app”;
“_kMDItemContentChangeDate” = “2020-07-17 08:17:51 +0000”;
“_kMDItemCreationDate” = “2016-09-26 07:41:50 +0000”;
“_kMDItemCreatorCode” = 0;
“_kMDItemDisplayNameWithExtensions” = {
“” = “XQuartz.app”;
};
“_kMDItemFileName” = “XQuartz.app”;
“_kMDItemFinderFlags” = 0;
“_kMDItemFinderLabel” = 0;
“_kMDItemFromImporter” = 1;
“_kMDItemIsExtensionHidden” = 1;
“_kMDItemIsFromImporter” = 1;
“_kMDItemNodeCount” = 1;
“_kMDItemOwnerGroupID” = 0;
“_kMDItemOwnerUserID” = 0;
“_kMDItemTypeCode” = 0;
“com_apple_metadata_modtime” = “616666671.485049”;
kMDItemAlternateNames = (
“XQuartz.app”
);
kMDItemAppStoreCategory = {
“” = Utilities;
ar = “\U0627\U0644\U0623\U062f\U0648\U0627\U062a \U0627\U0644\U0645\U0633\U0627\U0639\U062f\U0629”;
ca = Utilitats;
cs = Utility;
da = “Hj\U00e6lpeprogrammer”;
de = Dienstprogramme;
el = “\U0392\U03bf\U03b7\U03b8\U03ae\U03bc\U03b1\U03c4\U03b1”;
en = Utilities;
“en_AU” = Utilities;
“en_GB” = Utilities;
es = Utilidades;
“es_419” = Utilidades;
fi = “Lis\U00e4ohjelmat”;
fr = Utilitaires;
“fr_CA” = Utilitaires;
he = “\U05db\U05dc\U05d9 \U05e2\U05d6\U05e8”;
hi = “\U092f\U0942\U091f\U093f\U0932\U093f\U091f\U0940”;
hr = “Uslu\U017eni programi”;
hu = “Seg\U00e9dprogramok”;
id = Utilitas;
it = Utility;
ja = “\U30e6\U30fc\U30c6\U30a3\U30ea\U30c6\U30a3”;
ko = “\Uc720\Ud2f8\Ub9ac\Ud2f0”;
ms = Kemudahan;
nl = “Hulpprogramma’s”;
no = “Verkt\U00f8y”;
pl = “Narz\U0119dzia”;
pt = “Utilit\U00e1rios”;
“pt_PT” = “Utilit\U00e1rios”;
ro = Utilitare;
ru = “\U0423\U0442\U0438\U043b\U0438\U0442\U044b”;
sk = Utility;
sv = Verktyg;
th = “\U0e22\U0e39\U0e17\U0e34\U0e25\U0e34\U0e15\U0e35\U0e49”;
tr = “\U0130zlenceler”;
uk = “\U0423\U0442\U0438\U043b\U0456\U0442\U0438”;
vi = “Ti\U1ec7n \U00edch”;
“zh_CN” = “\U5b9e\U7528\U5de5\U5177”;
“zh_HK” = “\U5de5\U5177\U7a0b\U5f0f”;
“zh_TW” = “\U5de5\U5177\U7a0b\U5f0f”;
};
kMDItemAppStoreCategoryType = “public.app-category.utilities”;
kMDItemCFBundleIdentifier = “org.macosforge.xquartz.X11”;
kMDItemContentCreationDate = “2016-09-26 07:41:50 +0000”;
kMDItemContentModificationDate = “2020-07-17 08:17:51 +0000”;
kMDItemContentType = “com.apple.application-bundle”;
kMDItemContentTypeTree = (
“com.apple.application-bundle”,
“com.apple.application”,
“public.executable”,
“com.apple.localizable-name-bundle”,
“com.apple.bundle”,
“public.directory”,
“public.item”,
“com.apple.package”
);
kMDItemCopyright = {
“” = "\U00a9 2003-2016 Apple Inc. \U00a9 2003 XFree86 Project, Inc. \U00a9 2003-2016 X.org Foundation, Inc. ";
};
kMDItemDateAdded = “2020-06-21 08:35:01 +0000”;
kMDItemDisplayName = {
“” = XQuartz;
};
kMDItemDocumentIdentifier = 0;
kMDItemKind = {
“” = Application;
ar = “\U062a\U0637\U0628\U064a\U0642”;
ca = “Aplicaci\U00f3”;
cs = Aplikace;
da = Program;
de = Programm;
el = “\U0395\U03c6\U03b1\U03c1\U03bc\U03bf\U03b3\U03ae”;
en = Application;
“en_AU” = Application;
“en_GB” = Application;
es = “Aplicaci\U00f3n”;
“es_419” = “Aplicaci\U00f3n”;
fi = Appi;
fr = Application;
“fr_CA” = Application;
he = “\U05d9\U05d9\U05e9\U05d5\U05dd”;
hi = “\U0910\U092a\U094d\U0932\U093f\U0915\U0947\U0936\U0928”;
hr = Aplikacija;
hu = “Alkalmaz\U00e1s”;
id = Aplikasi;
it = Applicazione;
ja = “\U30a2\U30d7\U30ea\U30b1\U30fc\U30b7\U30e7\U30f3”;
ko = “\Uc751\Uc6a9 \Ud504\Ub85c\Uadf8\Ub7a8”;
ms = Aplikasi;
nl = App;
no = Program;
pl = aplikacja;
pt = Aplicativo;
“pt_PT” = “Aplica\U00e7\U00e3o”;
ro = “Aplica\U021bie”;
ru = “\U041f\U0440\U043e\U0433\U0440\U0430\U043c\U043c\U0430”;
sk = “Aplik\U00e1cia”;
sv = Program;
th = “\U0e41\U0e2d\U0e1e\U0e1e\U0e25\U0e34\U0e40\U0e04\U0e0a\U0e31\U0e48\U0e19”;
tr = Uygulama;
uk = “\U041f\U0440\U043e\U0433\U0440\U0430\U043c\U0430”;
vi = “\U1ee8ng d\U1ee5ng”;
“zh_CN” = “\U5e94\U7528\U7a0b\U5e8f”;
“zh_HK” = “\U61c9\U7528\U7a0b\U5f0f”;
“zh_TW” = “\U61c9\U7528\U7a0b\U5f0f”;
};
kMDItemVersion = “2.7.11”;
}

but the metadata is not available in mdls, since the index seems to be broken:

mdls -name kMDItemVersion /Applications/Utilities/XQuartz.app
kMDItemVersion = (null)

I am currently trying to rebuild the index and see if all the metadata shows up.

Rebuilding the Spotlight index for the whole drive did not fix the issue. Since it seems that the indexing in the “/Applications” directory was still disabled.

Careful with “sudo mdutil -E”. It will cause each local store for the volumes indicated to be erased. The stores will be rebuilt if appropriate.

To check the indexing status “sudo mdutil -s” can be used instead.

user@MBP /Applications % sudo mdutil -E /Applications

/System/Volumes/Data/Applications:
2020-07-23 10:40:51.171 mdutil[41004:1597023] mdutil disabling Spotlight: /System/Volumes/Data/Applications -> kMDConfigSearchLevelFSSearchOnly
Indexing disabled.

Switching on indexing:

user@MBP /Applications % sudo mdutil -i on /Applications

/System/Volumes/Data/Applications:
Indexing enabled.

Now “mdls” reports the all metadata entries and the KNIME is able to
confirm the R installation and runs without any issues.

user@MBP Utilities % mdls XQuartz.app

_kMDItemDisplayNameWithExtensions = “XQuartz.app”
kMDItemAlternateNames = (
“XQuartz.app”
)
kMDItemAppStoreCategory = “Utilities”
kMDItemAppStoreCategoryType = “public.app-category.utilities”
kMDItemCFBundleIdentifier = “org.macosforge.xquartz.X11”
kMDItemContentCreationDate = 2016-09-26 07:41:50 +0000
kMDItemContentCreationDate_Ranking = 2016-09-26 00:00:00 +0000
kMDItemContentModificationDate = 2020-07-23 08:23:54 +0000
kMDItemContentModificationDate_Ranking = 2020-07-23 00:00:00 +0000
kMDItemContentType = “com.apple.application-bundle”
kMDItemContentTypeTree = (
“com.apple.application-bundle”,
“com.apple.application”,
“public.executable”,
“com.apple.localizable-name-bundle”,
“com.apple.bundle”,
“public.directory”,
“public.item”,
“com.apple.package”
)
kMDItemCopyright = "© 2003-2016 Apple Inc. © 2003 XFree86 Project, Inc. © 2003-2016 X.org Foundation, Inc. "
kMDItemDateAdded = 2020-06-21 08:35:01 +0000
kMDItemDateAdded_Ranking = 2020-06-21 00:00:00 +0000
kMDItemDisplayName = “XQuartz.app”
kMDItemDocumentIdentifier = 0
kMDItemFSContentChangeDate = 2020-07-23 08:23:54 +0000
kMDItemFSCreationDate = 2016-09-26 07:41:50 +0000
kMDItemFSCreatorCode = “”
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = “XQuartz.app”
kMDItemFSNodeCount = 1
kMDItemFSOwnerGroupID = 0
kMDItemFSOwnerUserID = 0
kMDItemFSSize = 1
kMDItemFSTypeCode = “”
kMDItemInterestingDate_Ranking = 2020-07-23 00:00:00 +0000
kMDItemKind = “Application”
kMDItemLogicalSize = 7949322
kMDItemPhysicalSize = 8499200
kMDItemVersion = “2.7.11”

I hope that this helps other people in the future!

Cheers
Oliver

4 Likes

Hi @oliveralka,

glad you figured it out and it’s working now :+1:

Br,
Ivan

Awesome that you were able to fix the problem and thanks a lot for sharing your insides with us!

Best
Mark

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.