Rails 在 Ubuntu 上遇到 rb-inotify 和 ffi 版本相关的诡异问题

diguage · 2013年07月05日 · 最后由 ywjno 回复于 2013年07月05日 · 5298 次阅读

先说明一下背景:我在看《Ruby on Rails Tutorial》(第二版)。为了方便在没有网络的时候不影响实验。我就先把书中所有的 Gem 声明,都找出来放到的 Gemfile 中了。在 Win7 上搞,还比较顺利。(也有些小问题)。然后,因为我在 Gemfile 中添加了根据 系统信息加载不同 gem 的判断 ,就像部署到 Linux(这里是 Ubuntu)测试一下。然后诡异问题就出来。具体如下啊:

代码在 Github 上托管着。网址如下: https://github.com/diguage/rortutorial (这里的 rb-inotify 还是声明的 0.8.8 版)

rtutorial$ bundle install

Fetching source index from http://ruby.taobao.org/
nResolving dependencies...
You have requested:
  rb-inotify = 0.8.8

The bundle currently has rb-inotify locked at 0.9.0.
Try running `bundle update rb-inotify`


rtutorial$ bundle update rb-inotify

Fetching source index from http://ruby.taobao.org/
Resolving dependencies.............
You have requested:
  ffi ~> 1.0.0

The bundle currently has ffi locked at 1.9.0.
Try running `bundle update ffi`


rtutorial$ bundle update ffi

Fetching source index from http://ruby.taobao.org/
Resolving dependencies...
You have requested:
  rb-inotify = 0.8.8

The bundle currently has rb-inotify locked at 0.9.0.
Try running `bundle update rb-inotify`

Gemfile 中是这样声明 rb-inotify:

gem 'rb-inotify', '0.8.8'

然后,我根据提示,把 Gemfile 中的声明修改成如下:

gem 'rb-inotify', '~> 0.9.0'

然后还是报错。如下:

rtutorial$ bundle update

^Cdeployer@D0:~/rtutorial$ bundle install --without production
Fetching source index from http://ruby.taobao.org/
Resolving dependencies........
You have requested:
  ffi ~> 1.0.0

The bundle currently has ffi locked at 1.9.0.
Try running `bundle update ffi`



rtutorial$ bundle update ffi

Fetching source index from http://ruby.taobao.org/
Resolving dependencies.........
You have requested:
  ffi ~> 1.0.0

The bundle currently has ffi locked at 1.9.0.
Try running `bundle update ffi`


rtutorial$ bundle update ffi

Fetching source index from http://ruby.taobao.org/
Resolving dependencies...
You have requested:
  ffi ~> 1.0.0

The bundle currently has ffi locked at 1.9.0.
Try running `bundle update ffi`

请问,这个如何破?? 将 Gemfile.lock 删掉,重新 bundle 没有问题了。难道 Gemfile.lock 不是每次 bundle 都重新生成吗?如果不是,假如换系统,是不是就会遇到诡异问题?为啥在 Rails 风格规范中有如下一条:

不要把 `Gemfile.lock` 文件从版本控制里移除。这不是随机产生的文件 - 它确保你所有的组员执行 `bundle install` 时,获得相同版本的 gem 。

相同版本的 gem这个不是在 Gemfile 中就规定好了吗?

Rails 风格规范: https://github.com/JuanitoFatas/rails-style-guide/blob/master/README-zhCN.md

想把这个疑问发布到 Github 中的 Issue 中,但是怎么就找不到呢?莫非删除了?

Ruby 以及 RVM 版本信息如下:

~$ ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [i686-linux]

~$ rvm -v

rvm 1.20.12 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]

系统信息如下:

~$ uname -a
Linux D0 2.6.32-46-generic #108-Ubuntu SMP Thu Apr 11 15:55:01 UTC 2013 i686 GNU/Linux

~$ head -n 1 /etc/issue
Ubuntu 10.04.4 LTS \n \l

~$ cat /proc/cpuinfo 
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 9
model name  : Intel(R) Pentium(R) M processor 1600MHz
stepping    : 5
cpu MHz     : 600.000
cache size  : 1024 KB
fdiv_bug    : no
hlt_bug     : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 2
wp      : yes
flags       : fpu vme de pse tsc msr mce cx8 mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 tm pbe up bts est tm2
bogomips    : 1199.00
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 32 bits virtual
power management:

Gemsfile 的声明如下:

require 'rbconfig'

#source 'https://rubygems.org'
source 'http://ruby.taobao.org'

gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.0.4'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.11.0'
  gem 'guard-rspec', '1.2.1'
  gem 'guard-spork', '1.2.0'
  gem 'spork', '0.9.2'
  gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
  gem 'annotate', '2.5.0'  
end

group :production do
  gem 'pg', '0.12.2'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails', '2.0.2'

group :test do
  gem 'capybara', '1.1.2'

  if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i  #Windows?
    gem 'rb-fchange', '0.0.5'
    gem 'rb-notifu', '0.0.4'
    gem 'win32console', '1.3.0'
  elsif RbConfig::CONFIG['target_os'] =~ /linux|unix|freebsd/i  #Linux?
    gem 'rb-inotify', '~> 0.9.0'
    gem 'libnotify', '0.5.9'
  else   #Mac?
    gem 'capybara', '1.1.2'
    gem 'rb-fsevent', '0.9.1', :require => false
    gem 'growl', '1.0.3'
  end

  gem 'factory_girl_rails', '4.1.0'  
  gem 'cucumber-rails', '1.2.1', require: false
  gem 'database_cleaner', '0.7.0'  
end

# To use debugger
gem 'debugger'

Ubuntu 下的 Gemfile.lock 如下:

GEM
  remote: http://ruby.taobao.org/
  specs:
    actionmailer (3.2.13)
      actionpack (= 3.2.13)
      mail (~> 2.5.3)
    actionpack (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
    activerecord (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
    activesupport (3.2.13)
      i18n (= 0.6.1)
      multi_json (~> 1.0)
    annotate (2.5.0)
      rake
    arel (3.0.2)
    bcrypt-ruby (3.0.1)
    bootstrap-sass (2.0.4.0)
    bootstrap-will_paginate (0.0.6)
      will_paginate
    builder (3.0.4)
    capybara (1.1.2)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    childprocess (0.3.9)
      ffi (~> 1.0, >= 1.0.11)
    coderay (1.0.9)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    columnize (0.3.6)
    cucumber (1.3.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12.0)
      multi_json (~> 1.3)
    cucumber-rails (1.2.1)
      capybara (>= 1.1.2)
      cucumber (>= 1.1.3)
      nokogiri (>= 1.5.0)
    database_cleaner (0.7.0)
    debugger (1.6.0)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.2.1)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.2.3)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (4.1.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.1.0)
      factory_girl (~> 4.1.0)
      railties (>= 3.0.0)
    faker (1.0.1)
      i18n (~> 0.4)
    ffi (1.9.0)
    formatador (0.2.4)
    gherkin (2.12.0)
      multi_json (~> 1.3)
    guard (1.8.1)
      formatador (>= 0.2.4)
      listen (>= 1.0.0)
      lumberjack (>= 1.0.2)
      pry (>= 0.9.10)
      thor (>= 0.14.6)
    guard-rspec (1.2.1)
      guard (>= 1.1)
    guard-spork (1.2.0)
      childprocess
      guard (>= 1.1)
      spork (>= 0.8.4)
      sys-proctable
    hike (1.2.3)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.0.2)
      railties (>= 3.2.0, < 5.0)
      thor (~> 0.14)
    json (1.8.0)
    libnotify (0.5.9)
    listen (1.2.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
      rb-kqueue (>= 0.2)
    lumberjack (1.0.4)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    method_source (0.8.1)
    mime-types (1.23)
    mini_portile (0.5.0)
    multi_json (1.7.7)
    nokogiri (1.6.0)
      mini_portile (~> 0.5.0)
    pg (0.12.2)
    polyglot (0.3.3)
    pry (0.9.12.2)
      coderay (~> 1.0.5)
      method_source (~> 0.8)
      slop (~> 3.4)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.13)
      actionmailer (= 3.2.13)
      actionpack (= 3.2.13)
      activerecord (= 3.2.13)
      activeresource (= 3.2.13)
      activesupport (= 3.2.13)
      bundler (~> 1.0)
      railties (= 3.2.13)
    railties (3.2.13)
      actionpack (= 3.2.13)
      activesupport (= 3.2.13)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.1.0)
    rb-fsevent (0.9.3)
    rb-inotify (0.9.0)
      ffi (>= 0.5.0)
    rb-kqueue (0.2.0)
      ffi (>= 0.5.0)
    rdoc (3.12.2)
      json (~> 1.4)
    rspec (2.11.0)
      rspec-core (~> 2.11.0)
      rspec-expectations (~> 2.11.0)
      rspec-mocks (~> 2.11.0)
    rspec-core (2.11.1)
    rspec-expectations (2.11.3)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.11.3)
    rspec-rails (2.11.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.11.0)
    rubyzip (0.9.9)
    sass (3.2.9)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.33.0)
      childprocess (>= 0.2.5)
      multi_json (~> 1.0)
      rubyzip
      websocket (~> 1.0.4)
    slop (3.4.5)
    spork (0.9.2)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.5)
    sys-proctable (0.9.3)
    thor (0.18.1)
    tilt (1.4.1)
    treetop (1.4.14)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.37)
    uglifier (2.1.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    websocket (1.0.7)
    will_paginate (3.0.3)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  annotate (= 2.5.0)
  bcrypt-ruby (= 3.0.1)
  bootstrap-sass (= 2.0.4)
  bootstrap-will_paginate (= 0.0.6)
  capybara (= 1.1.2)
  coffee-rails (~> 3.2.1)
  cucumber-rails (= 1.2.1)
  database_cleaner (= 0.7.0)
  debugger
  factory_girl_rails (= 4.1.0)
  faker (= 1.0.1)
  guard-rspec (= 1.2.1)
  guard-spork (= 1.2.0)
  jquery-rails (= 2.0.2)
  libnotify (= 0.5.9)
  pg (= 0.12.2)
  rails (= 3.2.13)
  rb-inotify (~> 0.9.0)
  rspec-rails (= 2.11.0)
  sass-rails (~> 3.2.3)
  spork (= 0.9.2)
  sqlite3 (= 1.3.5)
  uglifier (>= 1.0.3)
  will_paginate (= 3.0.3)

Win7 下的 Gemfile.lock 如下:

GEM
  remote: http://ruby.taobao.org/
  specs:
    actionmailer (3.2.13)
      actionpack (= 3.2.13)
      mail (~> 2.5.3)
    actionpack (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
    activerecord (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
    activesupport (3.2.13)
      i18n (= 0.6.1)
      multi_json (~> 1.0)
    annotate (2.5.0)
      rake
    arel (3.0.2)
    bcrypt-ruby (3.0.1-x86-mingw32)
    bootstrap-sass (2.0.4.0)
    bootstrap-will_paginate (0.0.6)
      will_paginate
    builder (3.0.4)
    capybara (1.1.2)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    childprocess (0.3.9)
      ffi (~> 1.0, >= 1.0.11)
    coderay (1.0.9)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    columnize (0.3.6)
    cucumber (1.3.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12.0)
      multi_json (~> 1.3)
    cucumber-rails (1.2.1)
      capybara (>= 1.1.2)
      cucumber (>= 1.1.3)
      nokogiri (>= 1.5.0)
    database_cleaner (0.7.0)
    debugger (1.6.0)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.2.1)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.2.3)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (4.1.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.1.0)
      factory_girl (~> 4.1.0)
      railties (>= 3.0.0)
    faker (1.0.1)
      i18n (~> 0.4)
    ffi (1.9.0-x86-mingw32)
    formatador (0.2.4)
    gherkin (2.12.0-x86-mingw32)
      multi_json (~> 1.3)
    guard (1.8.1)
      formatador (>= 0.2.4)
      listen (>= 1.0.0)
      lumberjack (>= 1.0.2)
      pry (>= 0.9.10)
      thor (>= 0.14.6)
    guard-rspec (1.2.1)
      guard (>= 1.1)
    guard-spork (1.2.0)
      childprocess
      guard (>= 1.1)
      spork (>= 0.8.4)
      sys-proctable
    hike (1.2.3)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.0.2)
      railties (>= 3.2.0, < 5.0)
      thor (~> 0.14)
    json (1.8.0)
    listen (1.2.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
      rb-kqueue (>= 0.2)
    lumberjack (1.0.4)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    method_source (0.8.1)
    mime-types (1.23)
    mini_portile (0.5.0)
    multi_json (1.7.7)
    nokogiri (1.6.0-x86-mingw32)
      mini_portile (~> 0.5.0)
    pg (0.12.2-x86-mingw32)
    polyglot (0.3.3)
    pry (0.9.12.2-x86-mingw32)
      coderay (~> 1.0.5)
      method_source (~> 0.8)
      slop (~> 3.4)
      win32console (~> 1.3)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.13)
      actionmailer (= 3.2.13)
      actionpack (= 3.2.13)
      activerecord (= 3.2.13)
      activeresource (= 3.2.13)
      activesupport (= 3.2.13)
      bundler (~> 1.0)
      railties (= 3.2.13)
    railties (3.2.13)
      actionpack (= 3.2.13)
      activesupport (= 3.2.13)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.1.0)
    rb-fchange (0.0.5)
      ffi
    rb-fsevent (0.9.3)
    rb-inotify (0.9.0)
      ffi (>= 0.5.0)
    rb-kqueue (0.2.0)
      ffi (>= 0.5.0)
    rb-notifu (0.0.4)
    rdoc (3.12.2)
      json (~> 1.4)
    rspec (2.11.0)
      rspec-core (~> 2.11.0)
      rspec-expectations (~> 2.11.0)
      rspec-mocks (~> 2.11.0)
    rspec-core (2.11.1)
    rspec-expectations (2.11.3)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.11.3)
    rspec-rails (2.11.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.11.0)
    rubyzip (0.9.9)
    sass (3.2.9)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.33.0)
      childprocess (>= 0.2.5)
      multi_json (~> 1.0)
      rubyzip
      websocket (~> 1.0.4)
    slop (3.4.5)
    spork (0.9.2)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.5-x86-mingw32)
    sys-proctable (0.9.3-x86-mingw32)
    thor (0.18.1)
    tilt (1.4.1)
    treetop (1.4.14)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.37)
    uglifier (2.1.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    wdm (0.1.0)
    websocket (1.0.7)
    will_paginate (3.0.3)
    win32console (1.3.0-x86-mingw32)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  annotate (= 2.5.0)
  bcrypt-ruby (= 3.0.1)
  bootstrap-sass (= 2.0.4)
  bootstrap-will_paginate (= 0.0.6)
  capybara (= 1.1.2)
  coffee-rails (~> 3.2.1)
  cucumber-rails (= 1.2.1)
  database_cleaner (= 0.7.0)
  debugger
  factory_girl_rails (= 4.1.0)
  faker (= 1.0.1)
  guard-rspec (= 1.2.1)
  guard-spork (= 1.2.0)
  jquery-rails (= 2.0.2)
  pg (= 0.12.2)
  rails (= 3.2.13)
  rb-fchange (= 0.0.5)
  rb-notifu (= 0.0.4)
  rspec-rails (= 2.11.0)
  sass-rails (~> 3.2.3)
  spork (= 0.9.2)
  sqlite3 (= 1.3.5)
  uglifier (>= 1.0.3)
  wdm (>= 0.1.0)
  will_paginate (= 3.0.3)
  win32console (= 1.3.0)

再升 ffi 啊

#1 楼 @Rei 怎么升啊?!这里没有 ffi 的声明啊。

#2 楼 @diguage Gemfile 和 Gemfile.lock 贴上来。

#3 楼 @Rei 贴了,发帖的时候,还想着。后来忘了。Gemfile.lock 还需要吗?这个不是根据 Gemfile 生成的吗? 这里只有 Win7 下的,Ubuntu 下的我看看有没有生成出来啊。

#4 楼 @diguage 要 Gemfile.lock,看看 ffi 是哪个 Gem 的依赖锁在了 1.9.0

#5 楼 @Rei 发了,第一次认真看 Gemfile.lock。哈哈

这似乎是 windows 下 bundle 的 Gemfile.lock 带到 Linux 引起的情况?我不知道怎么解决……或者把 Gemfile.lock 删了再 bundle。

#7 楼 @Rei 好的!我试试!!

win 下生成的 Gemfile.lock 到 linux 的时候还是需要重新运行「bundle install」的

需要 登录 后方可回复, 如果你还没有账号请 注册新账号