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

uninitialized constant Spring::SID::DL #274

Closed
teoljungberg opened this issue Mar 14, 2014 · 29 comments · Fixed by #357
Closed

uninitialized constant Spring::SID::DL #274

teoljungberg opened this issue Mar 14, 2014 · 29 comments · Fixed by #357
Labels

Comments

@teoljungberg
Copy link

Spring version: 1.12
Ruby version 1.9.3-p545

What more info can I provide?

/Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/sid.rb:17:in `fiddle_func': uninitialized constant Spring::SID::DL (NameError)
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/sid.rb:30:in `sid'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/sid.rb:39:in `pgid'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/server.rb:78:in `set_pgid'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/server.rb:34:in `boot'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/server.rb:14:in `boot'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/run.rb:36:in `block in boot_server'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/run.rb:34:in `fork'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/run.rb:34:in `boot_server'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/run.rb:18:in `call'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/command.rb:7:in `call'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/rails.rb:23:in `call'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client/command.rb:7:in `call'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/lib/spring/client.rb:26:in `run'
        from /Users/teo/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/spring-1.1.2/bin/spring:48:in `<top (required)>'
        from /Users/teo/.rbenv/versions/1.9.3-p545/bin/spring:23:in `load'
        from /Users/teo/.rbenv/versions/1.9.3-p545/bin/spring:23:in `<main>'
@CyborgMaster
Copy link

I just had a coworker set up a new mac and he ran into this error. It happened when he compiled ruby (via RVM) using clang, but didn't happen when ruby was compiled with apple-gcc42. Does spring support compilation with clang?

@benmoss
Copy link

benmoss commented Mar 24, 2014

I am getting this too, on spring 1.1.1

@tombeynon
Copy link

Same. This only started occurring after upgrading to Ruby 1.9.3-p545

@teoljungberg
Copy link
Author

I have the same issue on Ruby 1.9.3-p484 which has worked for me in the past

@viniciusoyama
Copy link

Same.
OSX 10.9, Ruby 1.9.3-p545 compiled with RVM and CLANG.
Spring 1.1.2

@taiki-t
Copy link

taiki-t commented Apr 3, 2014

Same. In my case changing the compiler to apple-gcc42 from clang solved the problem as CyborgMaster said. Thank you.

OSX 10.9
Ruby 1.9.3-p484
rbenv

@viniciusoyama
Copy link

Im my case changing the compiler to gcc46 solved the problem too. The problem is that when you compile using CLAN it doens't include the dynamic libraries. So when you try to use them with: "Spring::SID::DL" it doens't work.

@pigoz
Copy link
Contributor

pigoz commented Apr 9, 2014

The problem is fiddle_func in sid.rb is called regardless of the fact that DL is defined, while it should probably shell out if it's not (instead of crashing). I can prepare a patch if that's ok.

@jonleighton
Copy link
Member

Does require 'dl' (in irb) work for any of you folks? I'm wondering if it's just a missing require.

I think @pigoz's suggestion is good either way though - please do prepare a patch.

@viniciusoyama
Copy link

@jonleighton
It works when I compile the ruby 1.9.3 using gcc46. But when I use CLANG it doesn't work.
If you are using OSX you can instal using homebrew:
brew install gcc46
(wait 2 or 3 hours haha)
and then try
rvm reinstall 1.9.3

@teoljungberg
Copy link
Author

@jonleighton require'ing dl didn't help, it throws an error in irb

pigoz added a commit to pigoz/spring that referenced this issue Apr 10, 2014
When compiling Ruby 1.9.3 with clang, Fiddle is compiled in while DL is not.
This commit fixes an usage of the DL module in the case it's not compiled in.

Unfortunately Fiddle::Handle and Fiddle.dlopen were only added in Ruby 2, but
a dlopen call (available as part of the DL module) is needed to use
Fiddle::Function.

Fixes rails#274
@pigoz
Copy link
Contributor

pigoz commented Apr 10, 2014

See above commit, I am a little unsure if this actually solves the problem completely, since the code that shells out actually returns always 0 in my irb. Here's an example with Ruby 2:

irb(main):004:0> Process.getsid
=> 319
irb(main):005:0> `ps -p #{Process.pid} -o sess=`.to_i
=> 0

This is probably an OS X only issue though.

@caius
Copy link

caius commented Apr 11, 2014

I've just worked around this locally by recompiling my ruby using a patch from the FreeBSD lists, changing the compile flags for dl if clang is being used.

Used with ruby-install and my spring is happily bouncing along again (I put the patch in a gist to use: https://gist.github.com/caius/10452604):

$ ruby-install -p https://gist.githubusercontent.com/caius/10452604/raw/acd421a8461f4d776a8f752663db19e321f850e0/ext_dl_extconf_rb.patch ruby 1.9.3-p545
# <snip>
>>> Successfully installed ruby 1.9.3-p545 into /Users/caius/.rubies/ruby-1.9.3-p545

$ spring status
Spring is not running.

$ spring rails console
Loading development environment (Rails 3.2.16)
1.9.3 (main):0 > 

@caius
Copy link

caius commented Apr 11, 2014

@pigoz I'm also seeing the same behaviour from shelling out to ps to get the session id and it being zero. I see the same behaviour for other non-ruby processes on OS X too:

$ ps -p $(pgrep ssh-agent) -o sess=
     0

@jonleighton
Copy link
Member

Hmm, I've no idea why the ps command isn't working on OS X...

@maxime-d
Copy link

Same.
OSX 10.9.2, Ruby 1.9.3-p545 compiled with rbenv
Spring 1.1.2

I have resolved the problem compiling ruby with apple-gcc42.

@boxofrad
Copy link

boxofrad commented May 7, 2014

Same error on 1.9.3-p429 after reinstalling following upgrade to mavericks, with rbenv

@sobrinho
Copy link
Contributor

Same error here, OS X, ruby 1.9.3-p545 using rbenv and ruby-build.

@sobrinho
Copy link
Contributor

Although it works on ruby 2.1.1.

@calebx
Copy link

calebx commented May 29, 2014

Same error here, OS X, ruby 1.9.3-p545 using rbenv and ruby-build.
wtf...
i had try changing cc to gcc-4.6, and to gcc-4.2, both double times, all failed...

@kastman
Copy link

kastman commented Jun 25, 2014

ruby 1.9.3-p547 using rbenv and ruby-build also still fails currently

@jfairchild
Copy link

spring version 1.1.3, ruby 1.9.3-p545, and using compiler /opt/boxen/homebrew/bin/gcc-4.2
still fails.

@jonleighton jonleighton added the bug label Jul 7, 2014
@konyu
Copy link

konyu commented Jul 16, 2014

I got same bug.
OSX 10.9.4,
spring version 1.1.3,
ruby 1.9.3-p545(compile gcc-4.2)

Could you tell me what should I write more informations of my env?

@teoljungberg
Copy link
Author

I just tried out @pigoz patch and it works just fine on 1.9. I also tested against 2.1.2 to be safe.
@jonleighton Is it mergable into master?

@pigoz
Copy link
Contributor

pigoz commented Jul 16, 2014

I think it's better for you to compile Ruby with the FreeBSD patch posted by @caius (it's a one line patch)

@JezC
Copy link

JezC commented Jul 25, 2014

It's not just the use of clang, I think. Testing against various rubies that I have:

1.9.3-p0 - requires gcc - untested
1.9.3-p125 - first llvm version, spring works.
1.9.3-p547 - latest stable, spring fails
2.0.0-p481 - spring works
2.1.2-p95 - latest stable, spring is fine

From other reports, Spring works on later patch levels of 1.9.3, if using gcc. But it worked, at some point, on llvm on 1.9.3. And it now works on llvm with the latest stable ruby (2.1.2p95), and has worked on 2.0.0 at least at the most recent stable. There appears to be some range of 1.9.3 including the most recent stable, perhaps of other ruby patch levels, that fails.

Context: Mac OS X 10.9.4, Xcode 5.1.1, spring 1.1.3

@jgeiger
Copy link

jgeiger commented Oct 21, 2014

I found this fix on someone else branch and it seems github let me make a pull request from their branch to here. I didn't write the code, but I've used it, and it works quite well. It would solve this problem without making people jump though hoops.

@pigoz
Copy link
Contributor

pigoz commented Oct 21, 2014

@jgeiger I wrote that but we were unsure about using it because OS X bugs in ps :) See this comment for reference #274 (comment)

@jgeiger
Copy link

jgeiger commented Oct 21, 2014

Ah. It might be working for me and what I need, but not 100%. Thanks.

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

Successfully merging a pull request may close this issue.