2014-01-25 49 views
0

我想自定义haml-rails宝石,本地宝石失败on Rails的

所以我把它叉我在Github上项目,

然后复制到我的本地机器,并试图将其列入。

但它失败了。

我通过bundle update固定,但我不知道为什么它成功使用git,因为我认为它们是两个完全相同的项目。

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

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 => '[email protected]: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)$ 
+2

请删除图像,并将其替换为您看到的实际文字。图片实际上损害了你的问题的实用性,因为它们无法被搜索,这意味着当寻找类似问题的答案时,更少的人可以找到它们。 –

回答

1

正确,旧版本的HAML护栏宝石依赖于railites宝石3.2.14,该版本haml-导轨宝石,它被放置在规定的文件夹中,取决于铁路宝石4.0.1。所以,你必须要么:

  1. 取出的Gemfile和upgade所有的Rails4.x版版本。在大多数情况下,这个解决方案需要很多时间才能解决,而且不合适。

  2. 设置HAML护栏宝石放置在路径上的头,一个标签提交属于一个版本3.2.13 ,使一个新的分支,并在工作本地宝石:

    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 
    

    指定在上你的的Gemfile如下:

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

对不起,我不明白你的答案。如果我使用rails 3.2'和railties 3.x',我应该只更改'haml-rails'下的'Gemfile'?或者我应该检查以前版本的'haml-rails',它只支持rails 3? – newBike

+0

'git reset --hard 90dc86fa07e54ae9d56a202cf078f88b61a5cf5a'我运行了命令并返回到只需要s.add_dependency“railties”,[“> = 3.1”,“<4.1”]'的前一个版本。然后根据这个版本开发。你的意思是?谢谢 – newBike

+0

@poc yes我的意思就是这个,你基于版本在其他barnch上开发shell,这是正确的。 –