2014-01-25 52 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,這是正確的。 –