akihikodaki / cld3-ruby

cld3-ruby is an interface of Compact Language Detector v3 (CLD3) for Ruby.
Apache License 2.0
77 stars 22 forks source link

gem install cld3 -v '3.2.2' --source 'https://rubygems.org/' fails on MacOS #18

Closed jacobherrington closed 4 years ago

jacobherrington commented 6 years ago

@mdf092 just referenced this issue on #10 about 5 hours ago. Opening a new issue now that I am also experiencing it.

Behavior: Running gem install cld3 -v '3.2.2' --source 'https://rubygems.org/' fails with the following output:

Building native extensions. This could take a while...
ERROR:  Error installing cld3:
    ERROR: Failed to build gem native extension.

    current directory: /Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/cld3-3.2.2/ext/cld3
/Users/jacobherrington/.asdf/installs/ruby/2.5.1/bin/ruby -r ./siteconf20180920-96617-1fpfe1p.rb extconf.rb
Failed to locate protobuf

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/cld3-3.2.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/cld3-3.2.2 for inspection.
Results logged to /Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/cld3-3.2.2/gem_make.out

cat /Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/cld3-3.2.2/mkmf.log outputs:

"pkg-config --exists protobuf"
| pkg-config --libs protobuf
=> "-L/usr/local/Cellar/protobuf/3.6.1/lib -lprotobuf -pthread\n"
"clang -o conftest -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include/ruby-2.5.0/ruby/backward -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include/ruby-2.5.0 -I. -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib -L. -L/Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib  -fstack-protector -L/usr/local/lib     -lruby.2.5.1-static -framework Foundation  -lpthread -ldl -lobjc "
ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"clang -o conftest -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include/ruby-2.5.0/ruby/backward -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include/ruby-2.5.0 -I. -I/Users/jacobherrington/.asdf/installs/ruby/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib -L. -L/Users/jacobherrington/.asdf/installs/ruby/2.5.1/lib  -fstack-protector -L/usr/local/lib     -lruby.2.5.1-static -framework Foundation -L/usr/local/Cellar/protobuf/3.6.1/lib -lprotobuf -pthread -lpthread -ldl -lobjc "
ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

package configuration for protobuf is not found

For the sake of sanity, protoc --version outputs: libprotoc 3.6.1.

Environment: MacOS High Sierra 10.13.6, fish shell, Ruby 2.5.1, using asdf.

jacobherrington commented 6 years ago

Experiencing the same failure with Ruby 2.3.1 and cld3 3.1.3.

akihikodaki commented 6 years ago

Did you confirm your C compiler works? That would be the first step to solve the issue.

jacobherrington commented 6 years ago

@akihikodaki

gcc --version

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
#include<stdio.h>

int main(int argc, char* argv[]) {
    printf("Hello World\n");
    return 0;
}

Compiles with no issue.

akihikodaki commented 6 years ago

@jacobherrington Do you have these warnings which were present in mkmf.log? I forgot to ask to check the stdout.

ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.

mkmf considers any warnings fatal, so it is important that it quietly compiles. You may check https://github.com/akihikodaki/cld3-ruby#openbsd. (But don't apply suggested change. It should be the last resort.)

akihikodaki commented 6 years ago

By the way, I found a fix for the incovenient error detection is already applied on trunk: https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/mkmf.rb?r1=62007&r2=62006&pathrev=62007

It is not released yet but you may backport it if you cannot get rid of the warning (but you should try first, as I said earlier.)

mdf092 commented 6 years ago

For c file compile and run without issue

@jacobherrington Do you have these warnings which were present in mkmf.log? I forgot to ask to check the stdout.

ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.

mkmf considers any warnings fatal, so it is important that it quietly compiles. You may check https://github.com/akihikodaki/cld3-ruby#openbsd. (But don't apply suggested change. It should be the last resort.)

I did with out success. maybe I did on wrong file. I changed this: /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb There are some other files:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb
/MYUSERPATH/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb
/MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/mkmf.rb
/usr/local/lib/ruby/2.5.0/mkmf.rb
dpashkevich commented 6 years ago

I ran into the same issues.

First, I had to manually add the path to protobuf's library to PKG_CONFIG_PATH (why doesn't brew install protobuf do that???).

After doing that it would proceed to attempt to compile cld3 but fail because of compiler warnings as the original author points out.

I then replaced one line in /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb (per https://github.com/akihikodaki/cld3-ruby#openbsd) and the library finally compiled and installed.

@mdf092 maybe this is not working for you because a different version of ruby is currently active in your environment? Try running ruby --version and changing the mkmf.rb in the path for that version.

akihikodaki commented 6 years ago

I'm wondering why a few people had the same issue recently. Did Xcode 10.0 do something bad on their toolchains?

As I noted, the warning should be fixed rather if it can be. I found reports saying reinstalling Xcode fixes similar warnings on the Web. Can anyone confirm this?

dpashkevich commented 6 years ago

I set up a brand new development environment on osx a month and a half ago, so I assume I had the latest xcode installed

On Sat, Sep 22, 2018, 11:31 Akihiko Odaki notifications@github.com wrote:

I'm wondering why a few people had the same issue recently. Did Xcode 10.0 do something bad on their toolchains?

As I noted, the warning should be fixed rather if it can be. I found reports saying reinstalling Xcode fixes similar warnings on the Web. Can anyone confirm this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/akihikodaki/cld3-ruby/issues/18#issuecomment-423752024, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGqbRBFXCr1N9Qgf19n-17dPTQHDg6nks5udlfMgaJpZM4WyFPi .

-- Dmitry Pashkevich

mdf092 commented 6 years ago

I ran into the same issues.

First, I had to manually add the path to protobuf's library to PKG_CONFIG_PATH (why doesn't brew install protobuf do that???).

After doing that it would proceed to attempt to compile cld3 but fail because of compiler warnings as the original author points out.

I then replaced one line in /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb (per https://github.com/akihikodaki/cld3-ruby#openbsd) and the library finally compiled and installed.

@mdf092 maybe this is not working for you because a different version of ruby is currently active in your environment? Try running ruby --version and changing the mkmf.rb in the path for that version.

Thanks. I did as you said without any success :(

and @akihikodaki , I remove and install xcode for three times but didn't work.

it seems that protobuf is working smoothly as I ran: pkg-config --list-all | grep proto and the output is:

protobuf-lite                    Protocol Buffers - Google's Data Interchange Format
protobuf                         Protocol Buffers - Google's Data Interchange Format
akihikodaki commented 6 years ago

@dpashkevich

I set up a brand new development environment on osx a month and a half ago,

Thanks for that information. Xcode 10.0 was released "September 17, 2018", according to Wikipedia, s you may not have the version. You may update your Xcode but I wonder if it breaks cld3-ruby again. :(

@mdf092

and @akihikodaki , I remove and install xcode for three times but didn't work.

Your reports are very appreciated since I don't own Mac. I hope you can get cld3-ruby work soon.

mdf092 commented 6 years ago

@dpashkevich

I set up a brand new development environment on osx a month and a half ago,

Thanks for that information. Xcode 10.0 was released "September 17, 2018", according to Wikipedia, s you may not have the version. You may update your Xcode but I wonder if it breaks cld3-ruby again. :(

@mdf092

and @akihikodaki , I remove and install xcode for three times but didn't work.

  • Please tell me your Xcode version.
  • Check the Ruby version you currently use. You seem to have a few Ruby versions and you have to edit mkmf.rb of the appropriate version to workaround the issue.

Your reports are very appreciated since I don't own Mac. I hope you can get cld3-ruby work soon.

Thanks in advance for your help.

the xcode versin is: Version 9.4.1 (9F2000) xcode-select version 2349

command line tools:

package-id: com.apple.pkg.CLTools_Executables
version: 10.0.0.0.1.1535735448
volume: /
location: /
install-time: 1537369053
groups: com.apple.FindSystemFiles.pkg-group 
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

And this is the path of mkmf.rb: /MYUSERPATH/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb

akihikodaki commented 5 years ago

@mdf092 So you use (probably) latest command line tools and Ruby 2.5.1?

I wonder why mkmf.rb hack doesn't work for you. What about adding Kernel.#p call and see its output? Old-good printf debug.

tachyons commented 5 years ago

I had to install pkg-config

brew install pkg-config

roschaefer commented 5 years ago

I had the same error on Arch Linux for

gem install cld3 -v '3.2.3' --source 'https://rubygems.org/'

The solution was to install

pacman -S protobuf
victorbordo commented 5 years ago

I encountered the same error while installing cld3 -v 3.2.4 on macOS Mojave (10.14.5)

gem install cld3 -v '3.2.4' --source 'https://rubygems.org/'

Installing protobuf got it working

brew install protobuf
Grawl commented 4 years ago

macOS Catalina 10.15.2 (19C57) Ruby 2.6.5

trying to install Mastodon dependencies with bundle inistall

brew install protobuf helped me

akihikodaki commented 4 years ago

Now I can confirm it works on macOS Catalina 10.15.3.