5

我无法运行 Spring。这是错误日志。

myid-no-MacBook-Pro:myid$ spring
/Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/sid.rb:17:in `fiddle_func': uninitialized constant Spring::SID::DL (NameError)
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/sid.rb:30:in `sid'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/sid.rb:39:in `pgid'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/server.rb:76:in `set_pgid'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/server.rb:33:in `boot'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/server.rb:19:in `boot'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:33:in `block in boot_server'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:31:in `fork'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:31:in `boot_server'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:16:in `call'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/command.rb:7:in `call'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client.rb:23:in `run'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/bin/spring:6:in `<top (required)>'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/spring:19:in `load'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/spring:19:in `<main>'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/ruby_executable_hooks:15:in `eval'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/ruby_executable_hooks:15:in `<main>'
^C/Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:35:in `sleep': Interrupt
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:35:in `boot_server'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/run.rb:16:in `call'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client/command.rb:7:in `call'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/client.rb:23:in `run'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/bin/spring:6:in `<top (required)>'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/spring:19:in `load'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/spring:19:in `<main>'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/ruby_executable_hooks:15:in `eval'
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/ruby_executable_hooks:15:in `<main>'

我用:

  • 红宝石 1.9.3-p484
  • Rails3.2.17
  • 春天 0.0.10
  • 操作系统 10.9
  • rbenv

我尝试了其他一些测试。我认为这个问题是 1.9.3 特有的。

myid-no-MacBook-Pro:~ myid$ ruby -v
ruby 1.9.2p326 (2013-12-23 revision 44353) [x86_64-darwin13.1.0]
myid-no-MacBook-Pro:~ myid$ irb
irb(main):001:0> require 'fiddle'
=> true
irb(main):002:0> DL
=> DL
irb(main):003:0> require 'dl'
=> false
irb(main):004:0> DL
=> DL
irb(main):005:0> DL.fiddle?
=> true
irb(main):006:0> exit




myid-no-MacBook-Pro:~ myid$ rbenv global 1.9.3-p484
myid-no-MacBook-Pro:~ myid$ irb
irb(main):001:0> require 'fiddle'
LoadError: cannot load such file -- dl
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/fiddle.rb:4:in `<top (required)>'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from (irb):1
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/irb:12:in `<main>'
irb(main):002:0> DL
NameError: uninitialized constant DL
  from (irb):2
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/irb:12:in `<main>'
irb(main):003:0> require 'dl'
LoadError: cannot load such file -- dl
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from /Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from (irb):3
  from /Users/myid/.rbenv/versions/1.9.3-p484/bin/irb:12:in `<main>'
irb(main):004:0> exit




myid-no-MacBook-Pro:~ myid$ rbenv global 2.1.0
myid-no-MacBook-Pro:~ myid$ irb
irb(main):001:0> require 'fiddle'
=> true
irb(main):002:0> DL
NameError: uninitialized constant DL
  from (irb):2
  from /Users/myid/.rbenv/versions/2.1.0/bin/irb:11:in `<main>'
irb(main):003:0> require 'dl'
DL is deprecated, please use Fiddle
=> true
irb(main):004:0> DL
=> DL
irb(main):005:0> DL.fiddle?
=> true
irb(main):006:0> 
4

3 回答 3

6

如果更改 C 编译器不能解决您的问题,此补丁对我有帮助:https ://github.com/pigoz/spring/commit/11804d2fd3dce75e9b236666739cdf5b40934abd

只需在系统上找到文件(通过 查找 spring 的安装位置bundle show spring)并手动进行更改。

于 2014-08-05T05:06:24.407 回答
5

我找到了解决方案。

在我的情况下,将 c 编译器从 clang 更改为 apple-gcc42 后运行良好。这是我使用的命令。

$ rbenv uninstall 1.9.3-p484
$ which gcc-4.2
/usr/local/bin/gcc-4.2
$ CC=/usr/local/bin/gcc-4.2
$ rbenv install 1.9.3-p484
$ rbenv rehash

相关链接:https ://github.com/rails/spring/issues/274

于 2014-04-03T04:46:44.610 回答
2

这个问题似乎仅限于一系列 Ruby 1.9.3 补丁级别,在 Mac 上使用 Apple 提供的编译器编译。

  • Ruby 1.9.3-p125,用 Apple 的 LLVM,Spring 1.1.3 编译,可以工作
  • Ruby 1.9.3-p547(撰写本文时最新稳定版)、LLVM、Spring 1.1.3 - 失败。

我有几个最新的稳定版 LLVM 的 Ruby(2.0、2.1.2)补丁。他们工作。

因此,在 1.9.3 系列的某个时刻,在 p125 之后,Spring 在使用 LLVM 时停止工作。在某些时候,至少 2.0.0-p481、更高版本的 Ruby 版本和次要版本以及微型版本再次开始使用 LLVM。IOW,这看起来像是 Ruby 1.9.3 回归问题,可能是 Ruby 2.0.0 回归问题。我已经将我在 Github 上发现的内容记录为 Spring 问题。

现在,如果您需要 1.9.3 并且您需要 Mac 上的 Spring……考虑 Zeus。;)

于 2014-07-25T07:24:41.803 回答