asdf-community / asdf-r

R plugin for the asdf version manager
https://github.com/asdf-vm/asdf
GNU General Public License v2.0
28 stars 5 forks source link

Update README.md for mac osx users #2

Closed SgtPooki closed 3 years ago

SgtPooki commented 3 years ago

I required libxt and cairo to be installed, as well as modifying PATH, LDFLAGS, CPPFLAGS, and PKG_CONFIG_PATH as all the dependencies installed by those requested. I used regex and some find and replace to generate the export statements from the brew install output, so these could be combined into single statements per environment variable:

export PATH="/usr/local/opt/expat/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/expat/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/expat/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/expat/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export LDFLAGS="-L/usr/local/opt/expat/lib"
export CPPFLAGS="-I/usr/local/opt/expat/include"
export PKG_CONFIG_PATH="/usr/local/opt/expat/lib/pkgconfig"
export C_INCLUDE_PATH="/opt/X11/include:${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export LDFLAGS="-L/usr/local/opt/libffi/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/libffi/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/sqlite/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/sqlite/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/sqlite/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/python@3.8/bin:$PATH"
export PKG_CONFIG_PATH="/usr/local/opt/python@3.8/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/icu4c/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/icu4c/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export LDFLAGS="-L/usr/local/opt/libffi/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/libffi/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/sqlite/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/sqlite/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/sqlite/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/python@3.8/bin:$PATH"
export PKG_CONFIG_PATH="/usr/local/opt/python@3.8/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/icu4c/lib${LDFLAGS:+ }${LDFLAGS}"
export CPPFLAGS="-I/usr/local/opt/icu4c/include${CPPFLAGS:+ }${CPPFLAGS}"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
taiar commented 3 years ago

Hey @SgtPooki, thanks for the Mac OS updates and also the long env setup reference.

I'm thinking of a way to reference this content on the readme as well. As you already described very well here, I think that just to reference this pull request on the readme would be nice, what do you think?

PS: I can do it myself, I just want to know if you agree this is a good option :)

taiar commented 3 years ago

I just did, thank you!

SgtPooki commented 3 years ago

awesome :) Thanks

noahgaertner commented 2 years ago

Hi, I just tried following this guide and I get this error

configure: error: "liblzma library and headers are required"

despite having xz installed (which has now replaced liblzma) Do you know how I would go about fixing this? Thanks!

Nathaniel-Haines commented 2 years ago

@noahgaertner I am having the same issue, did you ever come across a solution?

noahgaertner commented 2 years ago

@noahgaertner I am having the same issue, did you ever come across a solution?

Nope, I ended up just installing it from brew directly @Nathaniel-Haines

Nathaniel-Haines commented 2 years ago

@noahgaertner fell upon a solution today! I think the problem was that the compiler could not locate lzma. After installing xz/lzma through:

brew install xz

the following worked for me:

R_EXTRA_CONFIGURE_OPTIONS="CFLAGS=-I/opt/homebrew/lib CPPFLAGS=-I/opt/homebrew/include LDFLAGS=-L/opt/homebrew/include --enable-R-shlib --with-cairo --with-x=no" asdf install R 4.1.0

hyiltiz commented 1 year ago

Is it possible to let the build script actually include CFLAGS=-I/opt/homebrew/lib CPPFLAGS=-I/opt/homebrew/include LDFLAGS=-L/opt/homebrew/include as additional paths to check for so end users do not have to dig until they end up here? @SgtPooki @taiar

SgtPooki commented 1 year ago

@hyiltiz i imagine not. Especially not assuming homebrew is installed on every machine.

CFLAGS can vary in location by system, and it’s pretty common for compiler flags to require consumer intervention and manual config, because the locations and flags can vary widely and need customization/overriding for various reasons

Idk if there’s a good library out there for automatic CFLAG settings for users who are only using a tool and not developing it, but there might be.

A switch on os/platform/arch with some sane defaults and guiding error messages could be a good middleground 🤷

hyiltiz commented 1 year ago

There may be a confusion here; I am asking if we should also check for those paths before setting the variables CFLAGS etc., without assuming the existence of homebrew. I think one of the problems the build system could solve is to check for the existence of libraries etc. under various highly-likely paths in the system, and set appropriate defaults. The user could still override if they so wish by mechanisms such as manual configs or environment variables etc.