darlinghq / darling

Darwin/macOS emulation layer for Linux
http://www.darlinghq.org
GNU General Public License v3.0
11.55k stars 446 forks source link

Cannot unshare UTS and IPC namespaces to create darling-init: Operation not permitted #1251

Closed chuiqin closed 1 year ago

chuiqin commented 1 year ago

I built darling inside docker. But when I run darling shell echo Hello world inside docker container, it appears Cannot unshare UTS and IPC namespaces to create darling-init: Operation not permitted

Steps To Reproduce You can repeat my error by following this code:

docker pull mauriciogg/darling:latest
docker run -it --rm -v /home/sdc/fcq/shiny/readySeu_rset:/opt mauriciogg/darling:latest
darling shell echo Hello world

And then the error happens:

Cannot unshare UTS and IPC namespaces to create darling-init: Operation not permitted

strace Output I run the code strace -f -u $USER darling shell in the container and get the error strace: Cannot find user 'darling'

root@39ef6de2d2d1:/project# strace -f -u $USER darling shell
strace: Cannot find user 'darling'

dmesg Output I run the code dmesg | grep 'overlay\|darling' in the container and get the error dmesg: read kernel buffer failed: Operation not permitted

root@39ef6de2d2d1:/project# dmesg | grep 'overlay\|darling'
dmesg: read kernel buffer failed: Operation not permitted

I hope I can get your help! Thank you!

LubosD commented 1 year ago

You can't run darling shell inside Docker, because that is what starts Darling's own container.

There should be Darling's Docker repository here on GirHub, maybe it has some useful hints.

chuiqin commented 1 year ago

Thanks for your reply! I'm trying to run the MAC version of R using darling, but I'm getting some weird errors:

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac$ darling shell echo Hello world
hello world

My darling works fine when I perform darling shell echo Hello world

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac$ darling shell ./bin/R
####### R_HOME_DIR ########
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/../
####### R_binary ########
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//bin/exec/R
Running R_binary
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//bin/exec/R
dyld: lazy symbol binding failed: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

dyld: dyld cache load error: shared cache file open() failed
dyld: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

abort_with_payload: reason: dyld cache load error: shared cache file open() failed
Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib
; code: 4

Mistakes happen. I first darling shell, then ./bin/R, got the same error:

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac$ darling shell

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac]$ ./bin/R
####### R_HOME_DIR ########
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/../
####### R_binary ########
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//bin/exec/R
Running R_binary
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//bin/exec/R
dyld: lazy symbol binding failed: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

dyld: dyld cache load error: shared cache file open() failed
dyld: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

abort_with_payload: reason: dyld cache load error: shared cache file open() failed
Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib
; code: 4
Abort trap: 6 (core dumped)

But on my MAC computer, ./bin/R works fine

You can repeat my error by following this code:

git clone https://github.com/selkamand/r-portable-mac.git
cd r-portable-mac/
darling shell ./bin/R

I am eager to get your help, thank you very much!

facekapow commented 1 year ago

This is a case of another missing symbol. However, unlike most other missing symbols, we actually do have the code for this already in Darling, within libinfo: https://github.com/darlinghq/darling-Libinfo/blob/2da2f971cf42730777292a21480ca2ec1b0b9f04/rpc.subproj/xdr_mem.c#L132

I can take a look at this and see why it's not being exported.

LubosD commented 1 year ago

@facekapow There are several xdr*.c files not included in the build.

facekapow commented 1 year ago

Ah okay, that would do it :smile: Is there any particular reason we exclude them?

LubosD commented 1 year ago

Ah okay, that would do it smile Is there any particular reason we exclude them?

No idea. I was also surprised.

chuiqin commented 1 year ago

@facekapow There are several xdr*.c files not included in the build.

Thanks for your reply! How should I fix them? I don't know why these files are lost during the bulid process. I followed this tutorial build and install, and during this process, no errors occurred.

facekapow commented 1 year ago

No, this isn't a problem on your end; these files are missing from our build configuration. I'm adding them now and testing; if all goes well, I'll commit it and let you know.

facekapow commented 1 year ago

@chuiqin Just pushed a commit that should fix this. Could you rebuild and try again? (after updating the sources: https://docs.darlinghq.org/build-instructions.html#updating-sources)

chuiqin commented 1 year ago

@facekapow Thanks a lot for your work, let me try it out and give you feedback on the results.

chuiqin commented 1 year ago

@facekapow I update darling with the following code, but encountered the following error during the make process:

git pull
git submodule update --init --recursive

error:

[ 71%] Linking C shared library AuthenticationServices
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NSImage", referenced from:
      __OBJC_$_CATEGORY_NSImage_$_ASImageExtras in NSImage+ASImageExtras.m.o
  "_OBJC_CLASS_$_NSPasteboard", referenced from:
      __OBJC_$_CATEGORY_NSPasteboard_$_AuthenticationServicesExtras in NSPasteboard+AuthenticationServicesExtras.m.o
  "_OBJC_CLASS_$_NSStackView", referenced from:
      __OBJC_$_CATEGORY_NSStackView_$_ASCredentialPickerPaneViewController in NSStackView+ASCredentialPickerPaneViewController.m.o
  "_OBJC_CLASS_$_NSViewController", referenced from:
      __OBJC_$_CATEGORY_NSViewController_$_AuthenticationServicesExtras in NSViewController+AuthenticationServicesExtras.m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/frameworks/AuthenticationServices/CMakeFiles/AuthenticationServices.dir/build.make:1587: src/frameworks/AuthenticationServices/AuthenticationServices] Error 1
make[1]: *** [CMakeFiles/Makefile2:58991: src/frameworks/AuthenticationServices/CMakeFiles/AuthenticationServices.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I copied the darling software to another server for make, and I also encountered the same error, hoping to get your help

CuriousTommy commented 1 year ago

@chuiqin Grab the latest version, I recently fixed this issue https://github.com/darlinghq/darling/issues/1252

chuiqin commented 1 year ago

I'm very sorry. Even though I'm using the latest version of darling, I still can't execute darling shell ./bin/R. I still got the same error as before.

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac/bin$ darling --version
darling master @ 0f56b1165
Copyright (C) 2012-2020 Lubos Dolezel

I am using the latest branch of darling.

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac/bin$ darling shell ./R
####### R_HOME_DIR ########
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/../
####### R_binary ########
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//bin/exec/R
Running R_binary
/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//bin/exec/R 
dyld: lazy symbol binding failed: Symbol not found: _xdrmem_create
  Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
  Expected in: /usr/lib/libSystem.B.dylib

dyld: dyld cache load error: shared cache file open() failed
dyld: Symbol not found: _xdrmem_create
  Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
  Expected in: /usr/lib/libSystem.B.dylib

abort_with_payload: reason: dyld cache load error: shared cache file open() failed
Symbol not found: _xdrmem_create
  Referenced from: /Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin/..//lib/libR.dylib
  Expected in: /usr/lib/libSystem.B.dylib
; code: 4

You can repeat my error by following this code:

git clone https://github.com/selkamand/r-portable-mac.git
cd r-portable-mac/
darling shell ./bin/R

I try something else Then, I was thinking if I can avoid this error if I start the installation from the pkg file. I downloaded the R-4.2.2.pkg file from the R official website, and then passed darling shell and installer -pkg R-4.2.2.pkg -target / proceed with the installation. There is no error during the installation process, but when starting R, the same error as above appears:

(base) fcq@ubt-Precision-7920-Tower:~/shiny$ darling shell

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny]$ installer -pkg R-4.2.2.pkg -target /
installer: Package name is R 4.2.2 for macOS
installer: Installing at base path /
installer: Installing selected choice R 4.2.2 Framework
installer: Installing package org.R-project.R.fw.pkg version 4.2.2 (133176 KB)
installer: Extracting files
installer: Installing selected choice R GUI 1.79
installer: Installing package org.R-project.R.GUI.pkg version 1.79 (4468 KB)
installer: Extracting files
installer: Installing selected choice Tcl/Tk 8.6.6
installer: Installing package org.r-project.x86_64.tcltk version 8.6.6 (32224 KB)
installer: Extracting files
installer: Installing selected choice Texinfo 6.7
installer: Installing package org.r-project.x86_64.texinfo version 6.7 (7326 KB)
installer: Extracting files
installer: Installation complete
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny]$ R
dyld: lazy symbol binding failed: Symbol not found: _xdrmem_create
  Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libR.dylib
  Expected in: /usr/lib/libSystem.B.dylib

dyld: dyld cache load error: shared cache file open() failed
dyld: Symbol not found: _xdrmem_create
  Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libR.dylib
  Expected in: /usr/lib/libSystem.B.dylib

abort_with_payload: reason: dyld cache load error: shared cache file open() failed
Symbol not found: _xdrmem_create
  Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libR.dylib
  Expected in: /usr/lib/libSystem.B.dylib
; code: 4
Abort trap: 6 (core dumped)
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny]$ 

You can also repeat my error by following this code:

wget -c https://cran.r-project.org/bin/macosx/base/R-4.2.2.pkg
darling shell
installer -pkg R-4.2.2.pkg -target /
R

Can you help me?

chuiqin commented 1 year ago

@facekapow I suspect it might be a problem with my machine. So I tried it on someone else's machine. But I still got the same error.

root@e256ef314edf:/opt/r-portable-mac/bin# darling shell ./Rscript --version
R scripting front-end version 4.0.0 (2020-04-24)
root@e256ef314edf:/opt/r-portable-mac/bin# darling shell echo Hello world
hello world
root@e256ef314edf:/opt/r-portable-mac/bin# darling shell

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Darling [/Volumes/SystemRoot/opt/r-portable-mac/bin]#
Darling [/Volumes/SystemRoot/opt/r-portable-mac/bin]# ./R
####### R_HOME_DIR ########
/Volumes/SystemRoot/opt/r-portable-mac/bin/../
####### R_binary ########
/Volumes/SystemRoot/opt/r-portable-mac/bin/..//bin/exec/R
Running R_binary
/Volumes/SystemRoot/opt/r-portable-mac/bin/..//bin/exec/R
dyld: lazy symbol binding failed: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/opt/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

dyld: dyld cache load error: shared cache file open() failed
dyld: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/opt/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

abort_with_payload: reason: dyld cache load error: shared cache file open() failed
Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/opt/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib
; code: 4
Abort trap: 6 (core dumped)

Interestingly, I found that I can view the version of R in the darling shell, and R will not report an error:

Darling [/Volumes/SystemRoot/opt/r-portable-mac/bin]# ./R --version
####### R_HOME_DIR ########
/Volumes/SystemRoot/opt/r-portable-mac/bin/../
####### R_binary ########
/Volumes/SystemRoot/opt/r-portable-mac/bin/..//bin/exec/R
Running R_binary
/Volumes/SystemRoot/opt/r-portable-mac/bin/..//bin/exec/R --version
R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.

However, when I checked the help of R, the same error as starting R appeared:

Darling [/Volumes/SystemRoot/opt/r-portable-mac/bin]# ./R --help
####### R_HOME_DIR ########
/Volumes/SystemRoot/opt/r-portable-mac/bin/../
####### R_binary ########
/Volumes/SystemRoot/opt/r-portable-mac/bin/..//bin/exec/R
Running R_binary
/Volumes/SystemRoot/opt/r-portable-mac/bin/..//bin/exec/R --help
2023-01-03 14:10:45.347 R[74:74] _CFGetHostUUIDString: unable to determine UUID for host. Error: 78
WARNING: unknown option '--help'

dyld: lazy symbol binding failed: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/opt/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

dyld: dyld cache load error: shared cache file open() failed
dyld: Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/opt/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib

abort_with_payload: reason: dyld cache load error: shared cache file open() failed
Symbol not found: _xdrmem_create
   Referenced from: /Volumes/SystemRoot/opt/r-portable-mac/bin/..//lib/libR.dylib
   Expected in: /usr/lib/libSystem.B.dylib
; code: 4
Abort trap: 6 (core dumped)

This is very strange.

LubosD commented 1 year ago

Changes from @facekapow definitely fixed it for me:

Darling [/Volumes/SystemRoot/home/lubos/R-Portable-Mac/bin]$ ./R
/Volumes/SystemRoot/home/lubos/R-Portable-Mac/bin
*** R_HOME_DIR ***
/Volumes/SystemRoot/home/lubos/R-Portable-Mac

R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error: package or namespace load failed for ‘grDevices’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so':
  dlopen(/Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so, 6): Symbol not found: _kCGPDFContextCreator
  Referenced from: /Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so
  Expected in: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
 in /Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so
Error: package or namespace load failed for ‘graphics’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so':
  dlopen(/Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so, 6): Symbol not found: _kCGPDFContextCreator
  Referenced from: /Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so
  Expected in: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
 in /Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so
Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so':
  dlopen(/Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so, 6): Symbol not found: _kCGPDFContextCreator
  Referenced from: /Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so
  Expected in: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
 in /Volumes/SystemRoot/home/lubos/R-Portable-Mac/library/grDevices/libs/grDevices.so
During startup - Warning messages:
1: package ‘grDevices’ in options("defaultPackages") was not found 
2: package ‘graphics’ in options("defaultPackages") was not found 
3: package ‘stats’ in options("defaultPackages") was not found 

I had the same error as you before updating.

chuiqin commented 1 year ago

@LubosD Could you please share your darling version? Here is my darling version.

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac/bin$ darling --version
darling master @ 0f56b1165
Copyright (C) 2012-2020 Lubos Dolezel
LubosD commented 1 year ago

Same for me. Are you sure you did a darling shutdown after or before updating?

chuiqin commented 1 year ago

@LubosD @CuriousTommy @facekapow It's really amazing! darling shutdown is required when you update darling. When I execute darling shutdown, I can open R perfectly. Fantastic! Thanks for your help! Darling is really an amazing tool, running the mac version of R in linux for the first time.

(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac/bin$ darling shutdown
(base) fcq@ubt-Precision-7920-Tower:~/shiny/r-portable-mac/bin$ darling shell
Bootstrapping the container with launchd...

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ No protocol specified

Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ R

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:
1: package ‘grDevices’ in options("defaultPackages") was not found 
2: package ‘graphics’ in options("defaultPackages") was not found 
3: package ‘stats’ in options("defaultPackages") was not found 
chuiqin commented 1 year ago

@LubosD I'm sorry to bother you again at such a short time. I found that although I could start R, R was unable to load and download any R packages. R is a programming language, and it would be terrible not to be able to load R packages and install R packages. I installed R from the pkg file. But in the process of loading the R package stats and downloading the R package stats, R failed to load grDevices.so, internet.so and R_X11.so. It looks like darling is not loading these *.so files correctly. In my Mac computer, I can load and download the R package stats after I install R from the pkg file.

wget -c https://cran.r-project.org/bin/macosx/base/R-4.2.2.pkg
darling shell
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny]$ installer -pkg R-4.2.2.pkg -target /
installer: Package name is R 4.2.2 for macOS
installer: Installing at base path /
installer: Installing selected choice R 4.2.2 Framework
installer: Installing package org.R-project.R.fw.pkg version 4.2.2 (133176 KB)
installer: Uninstalling previous version 4.2.2
installer: Extracting files
installer: Installing selected choice R GUI 1.79
installer: Installing package org.R-project.R.GUI.pkg version 1.79 (4468 KB)
installer: Uninstalling previous version 1.79
installer: Extracting files
installer: Installing selected choice Tcl/Tk 8.6.6
installer: Installing package org.r-project.x86_64.tcltk version 8.6.6 (32224 KB)
installer: Uninstalling previous version 8.6.6
installer: Extracting files
installer: Installing selected choice Texinfo 6.7
installer: Installing package org.r-project.x86_64.texinfo version 6.7 (7326 KB)
installer: Uninstalling previous version 6.7
installer: Extracting files
installer: Installation complete
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny]$ R

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:
1: package ‘grDevices’ in options("defaultPackages") was not found 
2: package ‘graphics’ in options("defaultPackages") was not found 
3: package ‘stats’ in options("defaultPackages") was not found 
> library(stats)
Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/grDevices/libs/grDevices.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/grDevices/libs/grDevices.so, 6): Symbol not found: _kCGPDFContextCreator
  Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/library/grDevices/libs/grDevices.so
  Expected in: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
 in /Library/Frameworks/R.framework/Versions/4.2/Resources/library/grDevices/libs/grDevices.so
> install.packages("stats")
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//internet.so':
  dlopen(/Library/Frameworks/R.framework/Resources/modules//internet.so, 6): Symbol not found: _cccurve25519_make_key_pair
  Referenced from: /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
  Expected in: /usr/lib/libSystem.B.dylib
 in /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
2: In doTryCatch(return(expr), name, parentenv, handler) :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
  dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/modules/R_X11.so
  Reason: image not found
3: package ‘stats’ is a base package, and should not be updated

You can also repeat my error by following this code:

wget -c https://cran.r-project.org/bin/macosx/base/R-4.2.2.pkg
darling shell
installer -pkg R-4.2.2.pkg -target /
R
library(stats)
install.packages("stats")
HinTak commented 1 year ago

FWIW, last I checked darling does not support any GUI-related functionalities, so in particular, neither grDevices.so nor R_X11.so is expected to work at the moment. You may only use R in batch/ cmd mode.

chuiqin commented 1 year ago

@HinTak Thanks for your reply. I find that even in R CMD BATCH mode, I still can't install R packages. I enter install.packages("ggplot2", repos = "https://cloud.r-project.org"); cat('Hello, World')in code.R fle, and then execute R CMD BATCH code.R result.txt. Finally, I checked the result.txt file and found that only 'Hello, World' was output.

Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ cat code.R
install.packages("ggplot2",repos = "https://cloud.r-project.org")
cat('Hello, World')

Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ R CMD BATCH code.R result.txt
^[[A^[[ADarling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ cat code.R
install.packages("ggplot2",repos = "https://cloud.r-project.org")
cat('Hello, World')
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ R CMD BATCH code.R result.txt
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ cat result.txt 

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

During startup - Warning messages:
1: package ‘grDevices’ in options("defaultPackages") was not found 
2: package ‘graphics’ in options("defaultPackages") was not found 
3: package ‘stats’ in options("defaultPackages") was not found 
> install.packages("ggplot2",repos = "https://cloud.r-project.org")
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
  internet routines cannot be loaded
Warning: unable to access index for repository https://cloud.r-project.org/bin/macosx/contrib/4.2:
  internet routines cannot be loaded
Warning message:
package ‘ggplot2’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 
> cat('Hello, World')
Hello, World> 
> proc.time()
   user  system elapsed 
  0.580   0.154   0.559 
Darling [/Volumes/SystemRoot/home/sdc/fcq/shiny/r-portable-mac/bin]$ 

It seems that R did not load internet.so correctly.

chuiqin commented 1 year ago

I want to pack shiny program into exe or dmg file in linux. Window users can use the exe file to browse the shiny program I provided without installation, while mac users can browse the shiny program I provided with the dmg file without installation. I think it's a cool job. Currently, I use wine and electron to package the shing program on linux into an exe file that can be directly used by window users. However, I had trouble packaging shiny programs into dmg files on linux until I discovered the amazing tool darling. I am eager to install the specified R package for the mac version of R in darling, so that I can package the shiny program into a dmg file through electron and distribute it to mac users for use.

HinTak commented 1 year ago

Not sure about status of general Internet access in darling; but if you download the source tar ball manually outside darling, and do something like R CMD install <tarball> (sorry I haven't used R for a number of years, so don't remember the actual syntax of installing packages from downloaded tar balls. But I am still officially one of the package maintainers, and contributed to some of the deepest part of R a long time ago, so I used to know it quite well). It should work. Some R packages requires compilers etc and AFAIK xcode and homebrew works somewhat under darling. You will have to get those under darling. It will be a lot of work.

That said, I think ggplot2 is not expected to work in darling. Already said most GUI-related functionalities is not expected to work. R's graph plotting functionality uses cairo. What it does is basically doing the drawing on a virtual GUI screen, then do a screen dump... so it is GUI-related, even if no actual windows etc is being created...

facekapow commented 1 year ago

Closing this since the original issue was resolved.