neanderslob
neanderslob

Reputation: 2693

Refusing to link macOS-provided software: libiconv

In an effort to follow the steps posted here to get nokogiri working, I seem unable to link iconv properly.

When I run the command

brew link libiconv

I receive the following error:

Warning: Refusing to link macOS-provided software: libiconv
If you need to have libiconv first in your PATH run:
  echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.bash_profile

For compilers to find libiconv you may need to set:
  export LDFLAGS="-L/usr/local/opt/libiconv/lib"
  export CPPFLAGS="-I/usr/local/opt/libiconv/include"

I've added the above paths to my bash profile, reloaded the terminal, restarted the terminal and even tried restarting the computer as well but the error still persists. I've also tried reinstalling libiconv but to no avail (see output below).

$ brew reinstall libiconv 
==> Reinstalling libiconv 
==> Downloading https://homebrew.bintray.com/bottles/libiconv-1.16.mojave.bottle.tar.gz
Already downloaded: /Users/sam/Library/Caches/Homebrew/downloads/203933f4d9f3c2f0463012d85013a6c01bdb89fc4d435341315b4537de1dba78--libiconv-1.16.mojave.bottle.tar.gz
==> Pouring libiconv-1.16.mojave.bottle.tar.gz
==> Caveats
libiconv is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have libiconv first in your PATH run:
  echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.bash_profile

For compilers to find libiconv you may need to set:
  export LDFLAGS="-L/usr/local/opt/libiconv/lib"
  export CPPFLAGS="-I/usr/local/opt/libiconv/include"

==> Summary
🍺  /usr/local/Cellar/libiconv/1.16: 30 files, 2.4MB

Upvotes: 1

Views: 4106

Answers (1)

Simba
Simba

Reputation: 27608

libiconv is keg-only.

❯ brew info libiconv
libiconv: stable 1.16 (bottled) [keg-only]
Conversion library
https://www.gnu.org/software/libiconv/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libiconv.rb
==> Caveats
libiconv is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

In the post link given by you, linking libiconv is unneeded. Cause only the real installation location is used but not the linked one. Just skip this link step and run following command,

# use the real installation location is not preferred, cause it will
# break you once the libiconv is upgraded to a new version
gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.16

# you'd better pass the dir "/usr/local/opt/libiconv", 
# which serves as a link to the real installation location.
gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv

Upvotes: 5

Related Questions