bigdecimal icon indicating copy to clipboard operation
bigdecimal copied to clipboard

bigdecimal install error

Open xsmyqf opened this issue 1 year ago • 2 comments

I have installed ruby-dev,but still have error: ` gem install bigdecimal Building native extensions. This could take a while... ERROR: Error installing bigdecimal: ERROR: Failed to build gem native extension.

current directory: /opt/bitnami/ruby/lib/ruby/gems/3.1.0/gems/bigdecimal-3.1.8/ext/bigdecimal

/opt/bitnami/ruby/bin/ruby extconf.rb checking for __builtin_clz()... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/opt/bitnami/ruby/bin/$(RUBY_BASE_NAME) /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:490:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:616:in block in try_compile' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:565:in with_werror' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:616:in try_compile' from extconf.rb:6:in block in have_builtin_func' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:989:in block in checking_for' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:354:in block (2 levels) in postpone' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:324:in open' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:354:in block in postpone' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:324:in open' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:350:in postpone' from /opt/bitnami/ruby/lib/ruby/3.1.0/mkmf.rb:988:in checking_for' from extconf.rb:5:in have_builtin_func' from extconf.rb:18:in

'

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

/opt/bitnami/ruby/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0-static/bigdecimal-3.1.8/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/bitnami/ruby/lib/ruby/gems/3.1.0/gems/bigdecimal-3.1.8 for inspection. Results logged to /opt/bitnami/ruby/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0-static/bigdecimal-3.1.8/gem_make.out `

xsmyqf avatar Jul 03 '24 03:07 xsmyqf

I am also encountering this same error. Are there any system C headers / library dependencies that we need to install first?

wayneeseguin avatar Jul 03 '24 16:07 wayneeseguin

You may need libz-dev on ubuntu

thatsnotright avatar Jul 08 '24 20:07 thatsnotright

I am also experiencing this on a M1 Mac running Sonoma 14.5, and Ruby 3.3.3. It's happening when I try to build a binary with rbwasm. Looks like it's being caused by x86 headers being expected during compilation, but I am running arm64-darwin23:

have_header: checking for x86intrin.h... -------------------- no

In file included from conftest.c:3:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/x86intrin.h:15:
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/immintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
#error "This header is only meant to be used on x86 and x64 architecture"

gillisd avatar Jul 14 '24 20:07 gillisd

I'm also having this problem on M1 Mac. I'm trying to update Rails to 7.1.3.4 and I can't because it can't install the latest BigDecimal.

TeamRainless avatar Jul 31 '24 07:07 TeamRainless

I am also experiencing this on a M1 Mac running Sonoma 14.5, and Ruby 3.3.3. It's happening when I try to build a binary with rbwasm. Looks like it's being caused by x86 headers being expected during compilation, but I am running arm64-darwin23:

have_header: checking for x86intrin.h... -------------------- no

In file included from conftest.c:3:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/x86intrin.h:15:
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/immintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
#error "This header is only meant to be used on x86 and x64 architecture"

I was able to solve this for Sonoma 14.5. Apparently from 14.5 onward... they're not doing the whole "arch -arm64" thing anymore. Now Homebrew just works like it used to. But you have to get rid of all the arm64 stuff that you used to get it working on M1 in the first place. This basically means uninstalling and reinstalling Homebrew. Here's both the question and the solution that I wrote on StackOverflow: https://stackoverflow.com/questions/76928819/error-running-rvm-make-j8-rvm-install-on-macos-ventura-or-sonoma

You also have to replace all your old arm64 gems with x86_64 gems and replace your arm64 version of Ruby (you can see which one you're using with "rvm list") with an x86_64 version of Ruby.

After that... everything should just WORK.

Took me all day yesterday to figure this out... But I got there.

TeamRainless avatar Aug 02 '24 06:08 TeamRainless

I am also encountering this same error. Are there any system C headers / library dependencies that we need to install first?

If it helps, I had to install the following packages to get this working on ubuntu:

  • libjemalloc-dev
  • libgmp-dev

treacher avatar Aug 27 '24 01:08 treacher

Well my problem came from one of those M1 Macs. They'd made some kinda temporary drivers to get cocoapods and python working. But now there's official support, so I had to uninstall all the old ruby and coscoapods drivers and install the new ones.

Since then it's worked fine.

On Tue, Aug 27, 2024, 3:35 AM Michael Treacher @.***> wrote:

I am also encountering this same error. Are there any system C headers / library dependencies that we need to install first?

If it helps, I had to install the following packages to get this working on ubuntu:

  • libjemalloc-dev
  • libgmp-dev

— Reply to this email directly, view it on GitHub https://github.com/ruby/bigdecimal/issues/297#issuecomment-2311400108, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2KI54A5RWC4FT6BNWWFLDZTPJU7AVCNFSM6AAAAABKIXD2QCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJRGQYDAMJQHA . You are receiving this because you commented.Message ID: @.***>

TeamRainless avatar Aug 27 '24 02:08 TeamRainless

I have the same problem on linux. It appears to be a problema with unrecognized gcc command line options:

gcc: error: unrecognized command line option ‘-fdeclspec’ gcc: error: unrecognized command line option ‘-Wextra-tokens’; did you mean ‘-Wextra-semi’? gcc: error: unrecognized command line option ‘-Wdivision-by-zero’; did you mean ‘-Wdiv-by-zero’? gcc: error: unrecognized command line option ‘-Wshorten-64-to-32’

Any suggestions?

martinnicolas avatar Sep 04 '24 12:09 martinnicolas

@martinnicolas What version of GCC do you have installed? That seems like the version you have is incompatible, perhaps you're using a different compiler that masquerades as GCC? For instance https://stackoverflow.com/a/46610651

thatsnotright avatar Sep 04 '24 13:09 thatsnotright

Hi, Im using gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2). The command line options mentioned are not present on this gcc version.

martinnicolas avatar Sep 04 '24 14:09 martinnicolas

I think GCC command line options mentioned are pretty old, and could be replaced for new ones or removed.

martinnicolas avatar Sep 04 '24 14:09 martinnicolas

This solves this issue:

sudo apt install clang

export CC=/usr/bin/clang

export CXX=/usr/bin/clang++

martinnicolas avatar Sep 04 '24 16:09 martinnicolas

This happens to me in ruby 3.3.4 & 3.3.5, but works on 3.3.3

matgaw avatar Sep 05 '24 12:09 matgaw

@matgaw Hi, yes, everything is ok with Ruby 3.3.3. And I think that this Is happening only un Linux. Clang is default compiler on Mac.

martinnicolas avatar Sep 05 '24 12:09 martinnicolas

Could you show results of ruby -rrbconfig -e 'pp RbConfig::CONFIG.fetch_values("CC", "CFLAGS", "CPPFLAGS", "warnflags", "optflags", "debugflags")'?

And:

gcc: error: unrecognized command line option ‘-fdeclspec’
gcc: error: unrecognized command line option ‘-Wextra-tokens’; did you mean ‘-Wextra-semi’?
gcc: error: unrecognized command line option ‘-Wdivision-by-zero’; did you mean ‘-Wdiv-by-zero’?
gcc: error: unrecognized command line option ‘-Wshorten-64-to-32’

These options are for clang but not gcc.

It is curious that rbconfig.rb seems for ruby compiled with clang but gcc is used.

nobu avatar Sep 09 '24 02:09 nobu

Could anyone share a mkmf.log file?

nobu avatar Sep 09 '24 02:09 nobu

Hi!, Sure!. This is the result for ruby -rrbconfig -e 'pp RbConfig::CONFIG.fetch_values("CC", "CFLAGS", "CPPFLAGS", "warnflags", "optflags", "debugflags")'

["/usr/bin/clang", "-fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -fPIC", " ", "-Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef", "-O3 -fno-fast-math", "-ggdb3"]

martinnicolas avatar Sep 09 '24 02:09 martinnicolas

Note: I received similar reports while recent days.

  • https://ml.ruby-lang.org/archives/list/[email protected]/message/OI3BLGJEEZHEFHAYMCNU7AM5BV465R6T/
  • https://github.com/rubygems/rubygems/issues/1508#issuecomment-2336873801

It may caused by pre-built binary of rvm and its compiler.

hsbt avatar Sep 09 '24 02:09 hsbt

I'm using rvm by the way. And I think that this is not happening with Ruby docker image.

martinnicolas avatar Sep 09 '24 02:09 martinnicolas

@thatsnotright thanks,this method solved my problem.

install libz-dev on ubuntu

xsmyqf avatar Sep 09 '24 03:09 xsmyqf

I am also experiencing this on a M1 Mac running Sonoma 14.5, and Ruby 3.3.3. It's happening when I try to build a binary with rbwasm. Looks like it's being caused by x86 headers being expected during compilation, but I am running arm64-darwin23:

have_header: checking for x86intrin.h... -------------------- no

In file included from conftest.c:3:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/x86intrin.h:15:
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/immintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
#error "This header is only meant to be used on x86 and x64 architecture"

This "no" is expected on other than x86/x64 platforms, not an error. Just BigDecimal will use the functions defined in that header if it is usable, otherwise other alternatives.

nobu avatar Sep 09 '24 04:09 nobu

For M1 you have to completely uninstall and reinstall both RVM and homebrew. Then it should work just fine. This problem was introduced in 14.5.

On Mon, Sep 9, 2024, 6:29 AM Nobuyoshi Nakada @.***> wrote:

I am also experiencing this on a M1 Mac running Sonoma 14.5, and Ruby 3.3.3. It's happening when I try to build a binary with rbwasm. Looks like it's being caused by x86 headers being expected during compilation, but I am running arm64-darwin23:

have_header: checking for x86intrin.h... -------------------- no

In file included from conftest.c:3: In file included from /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/x86intrin.h:15: /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/immintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture" #error "This header is only meant to be used on x86 and x64 architecture"

This "no" is expected on other than x86/x64 platforms, not an error. Just BigDecimal will use the functions defined in that header if it is usable, otherwise other alternatives.

— Reply to this email directly, view it on GitHub https://github.com/ruby/bigdecimal/issues/297#issuecomment-2337089684, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2KI5365VBX3HYYDZYR4KTZVUP35AVCNFSM6AAAAABKIXD2QCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZXGA4DSNRYGQ . You are receiving this because you commented.Message ID: @.***>

TeamRainless avatar Sep 09 '24 04:09 TeamRainless

@martinnicolas I filed your issue to https://github.com/rubygems/rubygems/issues/8015

hsbt avatar Sep 09 '24 05:09 hsbt

@hsbt great!.. Thanks, I posted here what it looks to be a hack.. and I'm on the way with that, but Is good to know that people is taking this seriously.

martinnicolas avatar Sep 09 '24 05:09 martinnicolas

Hi! Development machine, Ubuntu 20.04.6 LTS, using rvm, the problem occurred when upgrading from ruby ​​3.3.3 to 3.3.5

  1. reinstalling rvm did not help
  2. rebooting the computer did not help
  3. installing libjemalloc-dev libgmp-dev build-essentials did not help
  4. upgrading gcc from version 9.4.0 to version 11.4.0 did not help

sudo nano /home/andrey/.rvm/gems/ruby-3.3.4/extensions/x86_64-linux/3.3.0/bigdecimal-3.1.8/mkmf.log Contents of the mkmf.log file

LD_LIBRARY_PATH=.:/home/andrey/.rvm/rubies/ruby-3.3.4/lib "/usr/bin/gcc -o conftest -I/home/andrey/.rvm/rubies/ruby-3.3.4/include/ruby-3.3.0/x86_64-linux -I/home/andrey/.rvm/rubies/ruby-3.3.4/include/ruby-3.3.0/ruby/backward -I/home/andrey/.rvm/rubies/ruby-3.3.4/include/ruby-3.3.0 -I. -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-d> gcc: error: unrecognized command-line option ‘-fdeclspec’ gcc: error: unrecognized command-line option ‘-Wextra-tokens’; did you mean ‘-Wextra-semi’? gcc: error: unrecognized command-line option ‘-Wdivision-by-zero’; did you mean ‘-Wdiv-by-zero’? gcc: error: unrecognized command-line option ‘-Wshorten-64-to-32’ checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char *argv) 4: { 5: return !!argv[argc]; 6: } / end */

Only the solution from @martinnicolas helped

sudo apt install clang
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

P.S. Used in production rbenv, haven't tried updating 3.3.3 -> 3.3.5 yet

askrynnikov avatar Sep 10 '24 06:09 askrynnikov

@askrynnikov Thank you for sharing that. Can you file it to https://github.com/rubygems/rubygems/issues/8015 ? The original report is completely different issue.

hsbt avatar Sep 10 '24 06:09 hsbt