yihui / xfun

Miscellaneous R functions
https://yihui.org/xfun/
Other
135 stars 28 forks source link

Problem with installing xfun package #84

Closed Kynlinn closed 5 months ago

Kynlinn commented 5 months ago

install.packages("~/Downloads/xfun_0.42.tar.gz", repos = NULL, type = "source")

  • installing source package ‘xfun’ ... package ‘xfun’ successfully unpacked and MD5 sums checked using staged installation ** libs xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun ERROR: compilation failed for package ‘xfun’
  • removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/xfun’ Warning in install.packages : installation of package ‘/Users/Marjolaine/Downloads/xfun_0.42.tar.gz’ had non-zero exit status

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 5 months ago

You seem to be on macOS (please follow the issue guide at the bottom of your post to provide session info). I wonder why you want to install a package from source instead of installing the pre-compiled binary package on CRAN.

Kynlinn commented 5 months ago

I am a beginner. Previously, I had this error Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : namespace 'xfun' 0.37 is already loaded, but >= 0.39 is required

I uninstalled the xfun package and tried to reinstall it

yihui commented 5 months ago

Then all you need to do is install.packages('xfun'). Or update packages.

I'm curious where you learned this (non-standard) way of installing R packages:

install.packages("~/Downloads/xfun_0.42.tar.gz", repos = NULL, type = "source")
Kynlinn commented 5 months ago

Screenshot 2024-03-21 at 11 51 59

It said "there is no package called ‘xfun’"

yihui commented 5 months ago

You shouldn't install packages inside an R Markdown document, otherwise you would be installing these packages over and over again each time you render the document, which is completely unnecessary. Packages only need to be installed once, and that should be done outside R Markdown (e.g., in your R console, or use the Packages pane in RStudio).

BTW, would you tell me where you learned the non-standard way of installing R packages as I asked above?

Kynlinn commented 5 months ago

Yes I just downloaded the package and opened it manually by searching in the lower right quadrant

Kynlinn commented 5 months ago

Screenshot 2024-03-21 at 15 25 44 That's how I did

yihui commented 5 months ago

The default value of the Install from dropdown menu is Repository (CRAN). I wonder why you changed it to Package Archive File, which made the installation more complicated.

The whole thing should have been as simple as "just run install.packages('xfun') in the R console", or "type the package name in the dialog and hit Install":

image

There is no need to manually download a package archive from CRAN or install it from source.

Kynlinn commented 5 months ago

I see it now. Yes, I made things complicated because I know zero about R. Thank you very much for your patient guidance!

yihui commented 5 months ago

You are welcome! Let me know if you have further trouble with installing the package.