Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install thin gem on macOS 11.0 Big Sur beta #365

Closed
yahonda opened this issue Jul 30, 2020 · 13 comments
Closed

Unable to install thin gem on macOS 11.0 Big Sur beta #365

yahonda opened this issue Jul 30, 2020 · 13 comments

Comments

@yahonda
Copy link

yahonda commented Jul 30, 2020

I'd like to know how to install thin gem on macOS 11.0 Big Sur beta.

  • Background:
    I'm contributing to Ruby on Rails framework using my macOS. One of the Rails module Action Cable uses blade gem, it requires thin gem.

  • Software versions

% sw_vers                                                                                                                                                                                                                   master
ProductName:	macOS
ProductVersion:	11.0
BuildVersion:	20A5323l
% ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin20]
% gem -v
3.1.2
% cc -v
Apple clang version 12.0.0 (clang-1200.0.26.2)
Target: x86_64-apple-darwin20.0.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • gem install thin command results
% gem install thin
Building native extensions. This could take a while...
ERROR:  Error installing thin:
	ERROR: Failed to build gem native extension.

    current directory: /Users/yahonda/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2/ext/thin_parser
/Users/yahonda/.rbenv/versions/2.7.1/bin/ruby -I /Users/yahonda/.rbenv/versions/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200730-33834-mbvks1.rb extconf.rb
checking for main() in -lc... yes
creating Makefile

current directory: /Users/yahonda/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2/ext/thin_parser
make "DESTDIR=" clean

current directory: /Users/yahonda/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2/ext/thin_parser
make "DESTDIR="
compiling parser.c
parser.c:31:18: warning: unused variable 'http_parser_en_main' [-Wunused-const-variable]
static const int http_parser_en_main = 1;
                 ^
1 warning generated.
compiling thin.c
thin.c:242:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  thin_http_parser_init(hp);
  ^
thin.c:242:3: note: did you mean 'http_parser_init'?
./parser.h:41:5: note: 'http_parser_init' declared here
int http_parser_init(http_parser *parser);
    ^
thin.c:260:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  thin_http_parser_init(http);
  ^
thin.c:277:3: error: implicit declaration of function 'thin_http_parser_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  thin_http_parser_init(http);
  ^
thin.c:294:3: error: implicit declaration of function 'thin_http_parser_finish' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  thin_http_parser_finish(http);
  ^
thin.c:294:3: note: did you mean 'Thin_HttpParser_finish'?
thin.c:290:7: note: 'Thin_HttpParser_finish' declared here
VALUE Thin_HttpParser_finish(VALUE self)
      ^
thin.c:296:10: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  return thin_http_parser_is_finished(http) ? Qtrue : Qfalse;
         ^
thin.c:334:5: error: implicit declaration of function 'thin_http_parser_execute' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    thin_http_parser_execute(http, dptr, dlen, from);
    ^
thin.c:334:5: note: did you mean 'Thin_HttpParser_execute'?
thin.c:317:7: note: 'Thin_HttpParser_execute' declared here
VALUE Thin_HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
      ^
thin.c:338:8: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if(thin_http_parser_has_error(http)) {
       ^
thin.c:338:8: note: did you mean 'http_parser_has_error'?
./parser.h:44:5: note: 'http_parser_has_error' declared here
int http_parser_has_error(http_parser *parser);
    ^
thin.c:359:10: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  return thin_http_parser_has_error(http) ? Qtrue : Qfalse;
         ^
thin.c:374:10: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  return thin_http_parser_is_finished(http) ? Qtrue : Qfalse;
         ^
9 errors generated.
make: *** [thin.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/yahonda/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thin-1.7.2 for inspection.
Results logged to /Users/yahonda/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-20/2.7.0/thin-1.7.2/gem_make.out
@yijia-zhan
Copy link

Catalina 10.15.6 has the exact same error:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.6
BuildVersion:	19G73

@yahonda
Copy link
Author

yahonda commented Aug 2, 2020

Opened a pull request #366

@yahonda
Copy link
Author

yahonda commented Aug 3, 2020

It should be addressed by #364.

@yahonda
Copy link
Author

yahonda commented Aug 3, 2020

Closing because #364 has been merged to master branch.

@yahonda yahonda closed this as completed Aug 3, 2020
@kellishaver
Copy link

kellishaver commented Sep 8, 2020

If you're in a situation where you can't upgrade the gem, upgrading to XCode 11.7 will fix the error above.

Note that if you've previously installed stand-alone command line tools, you'll have to switch to the ones included with XCode via sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

@ioquatix
Copy link
Collaborator

ioquatix commented Sep 8, 2020

Do you want to make a PR to update the README with those details @kellishaver ?

@kellishaver
Copy link

Do you want to make a PR to update the README with those details @kellishaver ?

Would be happy to! I'll do this tonight.

@mszyndel
Copy link

Alternative solution that has worked for me was

gem install thin -v '1.6.4' -- --with-cflags="-Wno-error=implicit-function-declaration"

This didn't require me to install XCode, just Command Line Tools

@WillSewell
Copy link

If you are using bundle install, you will need to run

bundle config build.thin --with-cflags="-Wno-error=implicit-function-declaration"

@timohuovinen
Copy link

This also worked for me

gem install thin 1.6.4 -- --build-flags --with-cflags="-Wno-error=unused-const-variable"  

@ZASMan
Copy link

ZASMan commented Jan 12, 2022

No luck with any of the solutions here for Monterey. Anyone else have this problem?

@hugocorbucci
Copy link

Just followed the suggestion from @mszyndel on Monterey and it worked just fine:

 gem install thin -v '1.6.4' -- --with-cflags="-Wno-error=implicit-function-declaration"

@aeberlin
Copy link

aeberlin commented Jan 16, 2025

If anybody is struggling to get 1.6.4 installed on mac Big Sur and xcode 13.2.1 on a really old mac book, the cflags solution wasn't enough, due to this repeated error

error: '__declspec' attributes are not enabled

This was my solution, adding -fdeclspec to cppflags:

gem install thin -v '1.6.4' -- --with-cflags="-Wno-error=implicit-function-declaration" --with-cppflags="-fdeclspec"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants