本地gem在Rails上失败了

时间:2014-01-25 05:21:53

标签: ruby-on-rails ruby gem bundler

我想自定义haml-rails gem,

所以我把它分到我在Github上的项目,

然后克隆到我的本地计算机并尝试包含它。

但它失败了。

我修复了bundle update,但我不知道为什么它成功使用git,因为我认为它们是两个相同的项目。

如果我使用Gemfilehaml-rails,我是否应该更改rails 3.2下的railties 3.x?或者我应该检查以前只支持rails 3的haml-rails版本?

enter image description here enter image description here

enter image description here

$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "railties":
  In snapshot (Gemfile.lock):
    railties (3.2.13)

  In Gemfile:
    haml-rails (>= 0) ruby depends on
      railties (>= 4.0.1) ruby

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
~/sandbox/la
$ cat Gemfile | grep haml
#gem "haml-rails"
gem "haml-rails", :path => "/Users/hsu-wei-cheng/Dropbox/Ruby/haml-rails"
# gem "haml-rails", :git => 'git@github.com:poc7667/haml-rails.git'
~/sandbox/la
$ cd /Users/hsu-wei-cheng/Dropbox/Ruby/haml-rails
~/Dropbox/Ruby/haml-rails
(feature/custom_view_for_dqa)$ tree -L 3
.
├── Appraisals
├── Gemfile
├── LICENSE
├── README.md
├── Rakefile
├── gemfiles
│   ├── rails_4_0.gemfile
│   └── rails_4_1.gemfile
├── haml-rails.gemspec
├── lib
│   ├── generators
│   │   └── haml
│   ├── haml-rails
│   │   └── version.rb
│   └── haml-rails.rb
└── test
    ├── fixtures
    │   └── routes.rb
    ├── lib
    │   └── generators
    └── test_helper.rb

9 directories, 12 files
~/Dropbox/Ruby/haml-rails
(feature/custom_view_for_dqa)$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Installing activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Installing actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Installing actionmailer (4.0.2)
Installing activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Installing activerecord (4.0.2)
Using bundler (1.3.5)
Installing appraisal (0.5.2)
Using tilt (1.4.1)
Using haml (4.0.5)
Using thor (0.18.1)
Installing railties (4.0.2)
Using haml-rails (0.5.3) from source at /Users/Hsu-Wei-Cheng/Dropbox/Ruby/haml-rails
Using hike (1.2.3)
Using sprockets (2.10.1)
Using sprockets-rails (2.0.1)
Installing rails (4.0.2)
Your bundle is updated!
~/Dropbox/Ruby/haml-rails
(feature/custom_view_for_dqa)$ bundle update
~/Dropbox/Ruby/haml-rails
(feature/custom_view_for_dqa)$ ls
Appraisals          LICENSE             gemfiles/           test/
Gemfile             README.md           haml-rails.gemspec
Gemfile.lock        Rakefile            lib/
~/Dropbox/Ruby/haml-rails
(feature/custom_view_for_dqa)$

1 个答案:

答案 0 :(得分:1)

正确地说,旧版本的 haml-rails gem取决于 railites gem 3.2.14 haml的版本-rails gem,放置在指定的文件夹中取决于 railites gem 4.0.1 。所以你要么:

  1. 删除 Gemfile 并将所有 Rails 升级到 4.x 版本。在大多数情况下,此解决方案需要花费很多时间来修复,并且不合适。

  2. 将放置在路径上的 haml-rails gem的HEAD设置为属于的标记提交一个版本 3.2.13 ,创建一个新的分支,并在本地处理gem:

    cd /path/to/gem/haml-rails
    git reset --hard <commit or tag>
    git branch your_branch
    git checkout your_branch
    # do something with the code
    

    在yuor Gemfile 中指定以下内容:

    gem 'haml-rails', :path => '/path/to/gem/haml-rails', :branch => 'your_branch'