Giter Site home page Giter Site logo

Comments (32)

mrkn avatar mrkn commented on July 24, 2024 13

@Hellfire01 I found that the problem also occurs on Ubuntu bionic.

The way to avoid this problem is explicitly specifying the version of bigdecimal by gem method like:

gem 'bigdecimal', '1.4.2'

The cause is require 'bigdecimal' loads bigdecimal.so of the default-gem version rather than of the gem-installed version.

I currently don't have the way to fix this correctly.

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024 2

I reported the problem of require method in Ruby 2.5 on CRuby's Redmine.
See https://bugs.ruby-lang.org/issues/15500

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

I couldn't reproduce the problem you were encountered:

irb(main):001:0> RUBY_DESCRIPTION
=> "ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]"
irb(main):002:0> gem 'rails', '5.2.2'
=> true
irb(main):003:0> gem 'bigdecimal', '1.4.2'
=> true
irb(main):004:0> require 'rails'
=> true

Could you investigate the cause of the problem on your environment?
If you don't have enough time for the investigation, please use bigdecimal 1.3.5 instead of 1.4.2.

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

Installed Ruby on an archlinux / manjaro environment ( up to date ) in a virtual machine

@Hellfire01 How can I get the same environment of this?

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@Hellfire01 I found that the cause is the behavior of require method on Ruby 2.5.3.

On Ruby 2.6 or 2.4.5, after installing bigdecimal 1.4.2, require 'bigdecimal' loads bigdecimal.so of the gem-installed version. However, in contrast, it loads bigdecimal.so of the default gem (the bundled version) on Ruby 2.5.3.

On Ruby 2.6.0:

$ docker run --rm -it rubylang/ruby:2.6.0-bionic
root@7e104185cf11:/# gem install bigdecimal
Fetching bigdecimal-1.4.2.gem
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.4.2
1 gem installed
root@7e104185cf11:/# ruby -ve 'require "bigdecimal"; p $LOADED_FEATURES.grep(/bigdecimal/)'
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
["/usr/local/lib/ruby/gems/2.6.0/gems/bigdecimal-1.4.2/lib/bigdecimal.so", "/usr/local/lib/ruby/gems/2.6.0/gems/bigdecimal-1.4.2/lib/bigdecimal.rb"]

On Ruby 2.5.3:

$ docker run --rm -it rubylang/ruby:2.5.3-bionic
root@689ce808458a:/# gem install bigdecimal
Fetching: bigdecimal-1.4.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.4.2
1 gem installed
root@689ce808458a:/# ruby -ve 'require "bigdecimal"; p $LOADED_FEATURES.grep(/bigdecimal/)'
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
["/usr/local/lib/ruby/2.5.0/x86_64-linux/bigdecimal.so"]

On Ruby 2.4.5:

$ docker run --rm -it rubylang/ruby:2.4-bionic
root@17a964abcb3a:/# gem install bigdecimal
Fetching: bigdecimal-1.4.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.4.2
1 gem installed
root@17a964abcb3a:/# ruby -ve 'require "bigdecimal"; p $LOADED_FEATURES.grep(/bigdecimal/)'
ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
["/usr/local/lib/ruby/gems/2.4.0/gems/bigdecimal-1.4.2/lib/bigdecimal.so", "/usr/local/lib/ruby/gems/2.4.0/gems/bigdecimal-1.4.2/lib/bigdecimal.rb"]

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

Will give you the output I have on all of the instructions you used as soon as I can have access to my computer.
To have the same environment, I could give you the virtual image of the VM I am using if you wish, you should have the same issue.
The environment is a new manjaro / archlinux one, it has nothing installed on it ( or at least, no program that would tamper with the environment that I would know about ). Installed Ruby with pacman and then installed the gem kimura - all of it's dependencies got installed automatically - and rails.
The issue occurs when one of those two gems tries to require bigdecimal. I have no issues when trying to directly load bigdecimal.

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@Hellfire01 Would you please examine the following step on your environment?

  1. Assume bigdecimal 1.4.2 is installed on Ruby 2.5.3 (it should already be satisfied)
  2. Execute irb
  3. Evaluate require "bigdecimal"
  4. Evaluate $LOADED_FEATURES.grep(/bigdecimal/)
  5. Report the last result here

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

will do

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

So, when I go a gem list I get bigdecimal (1.4.2, default: 1.3.4)
ruby --version outputs ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
And finaly, when I use irb and use the given instructions, I get :

irb(main):001:0> require "bigdecimal"
=> true
irb(main):002:0> $LOADED_FEATURES.grep(/bigdecimal/)
=> ["/usr/lib/ruby/2.5.0/x86_64-linux/bigdecimal.so"]

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@Hellfire01 Thank you for your investigation.
The result means your issue is due to the behavior of the require method in Ruby 2.5.

The easiest way to avoid this is specifying bigdecimal's version by gem method in your script or Gemfile.

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

thanks but I am unsure I can do that easily as the issue appears when I require rails or kimura with use the gem through active support. Not sure iff changing the gem files of the gems I use is a good idea.
Started using other gems in the mean time as I do not need them directly. If there is a big issue, I will very simply roll back on Ruby 2.4. Thank you for pointing that that version works

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@Hellfire01 Sorry for the inconvenience. I have no way to resolve this issue in bigdecimal.

By the way, I couldn't understand the reason why you cannot put gem "bigdecimal", "1.4.2" line in Gemfile. You don't need to modify any gem libraries. If you encountered this issue in your Rails application, you only need to modify Gemfile of your Rails application.

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

oh ok, thanks for the tip I will try that.
I usually only tend to do a require without a gemfile and thought that it was the gem that imposed the version of it's dependencies.

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@Hellfire01 I found the reason why 2.5's require is broken. This is it: https://bugs.ruby-lang.org/issues/15545

The next minor release of 2.5 may include the fix.

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@Hellfire01 Sorry, the previous comment is wrong. I believed that I found the cause of the bug, but I noticed that it is incorrect. The investigation is continued by the ruby core team.

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

thanks for the notification ^^

from bigdecimal.

vihai avatar vihai commented on July 24, 2024

This is becoming a major issue to me because a mere "gem update" will break any system with ruby 2.5.
Isn't there a way to prevent installing bigdecimal-1.4.3 on systems with incompatible ruby?

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@vihai You can stick a library version by adding the following line in Gemfile of your application:

gem "bigdecimal", "1.3.5"

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@vihai If you don't use bundler, you can stick a library version by adding gem "bigdecimal", "1.3.5" at the top of your script files.

from bigdecimal.

rafaelfranca avatar rafaelfranca commented on July 24, 2024

I'm using 2.5.5 and still having the same problem, was this already fixed?

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@rafaelfranca Could you tell me how to reproduce?

I confirmed that the problem has been fixed at 2.5.5:

On 2.5.5:

$ docker run --rm -it rubylang/ruby:2.5.5-bionic /bin/sh -exc 'gem install bigdecimal; ruby -v -rbigdecimal -rbigdecimal/util -ep'
+ gem install bigdecimal
Fetching bigdecimal-1.4.3.gem
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.4.3
1 gem installed
+ ruby -v -rbigdecimal -rbigdecimal/util -ep
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
$

On 2.5.3:

$ docker run --rm -it rubylang/ruby:2.5.3-bionic /bin/sh -exc 'gem install bigdecimal; ruby -v -rbigdecimal -rbigdecimal/util -ep'
+ gem install bigdecimal
Fetching: bigdecimal-1.4.3.gem (100%)
Building native extensions. This could take a while...
Successfully installed bigdecimal-1.4.3
1 gem installed
+ ruby -v -rbigdecimal -rbigdecimal/util -ep
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
Traceback (most recent call last):
        5: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        4: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        3: from /usr/local/lib/ruby/gems/2.5.0/gems/bigdecimal-1.4.3/lib/bigdecimal/util.rb:9:in `<top (required)>'
        2: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:34:in `require'
        1: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:130:in `require': /usr/local/lib/ruby/gems/2.5.0/gems/bigdecimal-1.4.3/lib/bigdecimal/util.so: undefined symbol: rmpd_util_str_to_d - /usr/local/lib/ruby/gems/2.5.0/gems/bigdecimal-1.4.3/lib/bigdecimal/util.so (LoadError)
$

from bigdecimal.

rafaelfranca avatar rafaelfranca commented on July 24, 2024

That is a good question 😅.

I'm using a ubuntu trusty image with a custom built ruby 2.5.5, totally based on the v2_5_5 tag. I'm not sure if I need to build ruby in a special way to avoid this issue or if this issue only happens because I'm using ubuntu trusty.

But by installing bigdecimal 1.4.3 and requiring bigdecimal/util on that setup I can reproduce that error.

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

@rafaelfranca

a custom built ruby 2.5.5

Could you please tell me the arguments of configure you specified?

I'm not sure if I need to build ruby in a special way to avoid this issue

As you can see in this build script, the ruby in the docker image I used for the previous confirmation is built in normal way.

from bigdecimal.

rafaelfranca avatar rafaelfranca commented on July 24, 2024

./configure --prefix="$(PREFIX)" --without-valgrind debugflags="-g3 -ggdb"` those are the arguments.

from bigdecimal.

bhagwandassoni1953 avatar bhagwandassoni1953 commented on July 24, 2024

So, when I go a gem list I get bigdecimal (1.4.2, default: 1.3.4)
ruby --version outputs ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
And finaly, when I use irb and use the given instructions, I get :

irb(main):001:0> require "bigdecimal"
=> true
irb(main):002:0> $LOADED_FEATURES.grep(/bigdecimal/)
=> ["/usr/lib/ruby/2.5.0/x86_64-linux/bigdecimal.so"]

Sorry to trouble you, for the same thing I'm getting [].

from bigdecimal.

bhagwandassoni1953 avatar bhagwandassoni1953 commented on July 24, 2024

@Hellfire01 Would you please examine the following step on your environment?

  1. Assume bigdecimal 1.4.2 is installed on Ruby 2.5.3 (it should already be satisfied)
  2. Execute irb
  3. Evaluate require "bigdecimal"
  4. Evaluate $LOADED_FEATURES.grep(/bigdecimal/)
  5. Report the last result here

[].

from bigdecimal.

Hellfire01 avatar Hellfire01 commented on July 24, 2024

I had to update Ruby in order to avoid having the issues ( using 2.6.3 currently, it has no issues with bigdecimal or rails ) and therefor I don't have the issues or the previous environment anymore.
I don't know if I can o something to help now sorry

from bigdecimal.

mrkn avatar mrkn commented on July 24, 2024

I've released the new version 1.4.4.
Please try with this version again.

from bigdecimal.

rafaelfranca avatar rafaelfranca commented on July 24, 2024

I'm now getting NoMethodError: undefined method interpret_loosely' for BigDecimal:Class`. The reasons is that maybe the C extension was cached by bundler and didn't compile again, but I'm posting here to see if anyone else got that.

from bigdecimal.

abeward avatar abeward commented on July 24, 2024

In the hopes that it helps someone: After trying everything, after verifying that it was already in my gem list, I just went ahead and experimentally ran gem install bigdecimal for giggles. That solved my problem and I can brew again fine now.

from bigdecimal.

Firooz-Bright avatar Firooz-Bright commented on July 24, 2024

Clear the gem file.lock by: removing all gems and redo bundle install solved the issue for me.

from bigdecimal.

Moh-Snoussi avatar Moh-Snoussi commented on July 24, 2024

In my case ubuntu-dev-tools was not installed:
sudo apt-get install ubuntu-dev-tools

from bigdecimal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.