Last active
December 12, 2015 12:19
-
-
Save Sixeight/4771462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Preference-ENGINE:/Users/tomohiro:(---) 2.0.0-rc2 | |
2:16:> irb | |
irb(main):001:0> require 'fiddle' | |
=> true | |
irb(main):002:0> DL | |
NameError: uninitialized constant DL | |
from (irb):2 | |
from /Users/tomohiro/.rbenv/versions/2.0.0-rc2/bin/irb:12:in `<main>' | |
irb(main):003:0> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Preference-ENGINE:/Users/tomohiro:(---) 2.0.0-rc2 | |
2:18:> irb | |
irb(main):001:0> require 'dl' | |
DL is deprecated, please use Fiddle | |
=> true | |
irb(main):002:0> DL | |
=> DL | |
irb(main):003:0> DL.fiddle? | |
=> true | |
irb(main):004:0> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Preference-ENGINE:/Users/tomohiro:(---) 1.9.3-p374 | |
2:18:> irb | |
irb(main):001:0> require 'fiddle' | |
=> true | |
irb(main):002:0> DL | |
=> DL | |
irb(main):003:0> DL.fiddle? | |
=> true | |
irb(main):004:0> |
We should use Fiddle
module instead of DL
(maybe)
For example:
$ rbenv shell 1.9.3-p385
$ irb
> require 'fiddle'
> DL::Handle::DEFAULT['getsid']
=> xxx
> Fiddle::Handle::DEFAULT['getsid']
NameError: uninitialized constant Fiddle::Handle
from (irb):3
from /Users/tomohiro/.rbenv/versions/1.9.3-p385/bin/irb:12:in `<main>'
> exit
$ rbenv shell 2.0.0-rc2
$ irb
> require 'fiddle'
> Fiddle::Handle::DEFAULT['getsid']
=> xxx
> DL::Handle::DEFAULT['getsid']
NameError: uninitialized constant DL
from (irb):2
from /Users/tomohiro/.rbenv/versions/2.0.0-rc2/bin/irb:12:in `<main>'
the problem appears in spring.
following code doesn't run with ruby 2.0.
https://github.com/jonleighton/spring/blob/master/lib/spring/sid.rb
DL is deprecated, please use Fiddle
oh...
Sorry, it's not convenient, but you need to conditionalize:
diff --git a/lib/spring/sid.rb b/lib/spring/sid.rb
index 632c694..c70e212 100644
--- a/lib/spring/sid.rb
+++ b/lib/spring/sid.rb
@@ -2,8 +2,14 @@ require 'fiddle'
module Spring
module SID
+ if RUBY_VERSION >= '2.0.0'
+ handle = Fiddle::Handle
+ else
+ handle = DL::Handle
+ end
+
FUNC = Fiddle::Function.new(
- DL::Handle::DEFAULT['getsid'],
+ handle::DEFAULT['getsid'],
[Fiddle::TYPE_INT],
Fiddle::TYPE_INT
)
I'll send a patch.
@tenderlove Thank you for your information!
and thank you for your patch for spring!
done: rails/spring#51
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related commit: ruby/ruby@c1fb6a8
old code requires 'dl' library when DL module was not defined.
ruby/ruby@c1fb6a8#L7L4