swirl icon indicating copy to clipboard operation
swirl copied to clipboard

failed to install swirl on M1

Open fdq09eca opened this issue 3 years ago • 1 comments

Here is my error.

> install.packages("swirl")
trying URL 'https://cran.rstudio.com/src/contrib/swirl_2.4.5.tar.gz'
Content type 'application/x-gzip' length 108847 bytes (106 KB)
==================================================
downloaded 106 KB

* installing *source* package ‘swirl’ ...
** package ‘swirl’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called ‘stringi’
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package ‘swirl’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/swirl’
Warning in install.packages :
  installation of package ‘swirl’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpxnFl7O/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
> install.packages("stringi")
trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.6.2.tar.gz'
Content type 'application/x-gzip' length 7575370 bytes (7.2 MB)
==================================================
downloaded 7.2 MB

ERROR: failed to lock directory ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library’ for modifying
Try removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/00LOCK-stringi’
Warning in install.packages :
  installation of package ‘stringi’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpxnFl7O/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

swirl is not the only package that has this problem, I have found several packages share this similarity.

ERROR: failed to lock directory ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library’ for modifying

I think this is the gist of the problem?

I could force the installation by the following

> install.packages("swirl", type="mac.binary")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/swirl_2.4.5.tgz'
Content type 'application/x-gzip' length 347422 bytes (339 KB)
==================================================
downloaded 339 KB


The downloaded binary packages are in
	/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T//RtmpxnFl7O/downloaded_packages
> install.packages("stringi", type="mac.binary")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.6.2.tgz'
Content type 'application/x-gzip' length 14596931 bytes (13.9 MB)
==================================================
downloaded 13.9 MB


The downloaded binary packages are in
	/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T//RtmpxnFl7O/downloaded_packages

but I still could not use it..

> library("swirl")
Error: package or namespace load failed for ‘swirl’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so':
  dlopen(/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so, 6): no suitable image found.  Did find:
	/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so: mach-o, but wrong architecture
	/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so: mach-o, but wrong architecture

fdq09eca avatar Jun 27 '21 23:06 fdq09eca

check the version of R that you have installed. was facing the very same issue i re-installed the package meant for m1 big sur, and swirl runs just fine!

link to the r package for m1 - https://cran.r-project.org/bin/macosx/big-sur-arm64/base/R-4.1.0-arm64.pkg

PrinJay25 avatar Aug 10 '21 19:08 PrinJay25