如何在Rails中只生成一个Gemfile?

时间:2012-09-21 18:06:33

标签: ruby-on-rails ruby-on-rails-3 bundle bundler rbenv

使用rbenv所以创建新应用程序的过程有点复杂:

  1. 创建目录
  2. cd directory
  3. 设置ruby版本:rbenv local 1.9.3-p125(或其他版本)
  4. 设置gemset:echo project-name > .rbenv-gemsets
  5. gem install rails -v 3.2.2 --no-rdoc --no-ri(例如)
  6. rbenv rehash
  7. echo "gem 'rails', '3.2.2'" > Gemfile
  8. bundle
  9. rails new .(输入y覆盖)
  10. bundle
  11. 之前有效,但这次我在rails new .命令上出错:

    ...
    ...
    create  vendor/assets/stylesheets
    create  vendor/assets/stylesheets/.gitkeep
    create  vendor/plugins
    create  vendor/plugins/.gitkeep
    run  bundle install
    b/gems/bundler-1.2.1/lib/bundler/resolver.rb:287:in `resolve': Could not find gem 'jquery-rails (>= 0) ruby' in the gems available on this machine. (Bundler::GemNotFound)
    

    第二次投掷rails new .

    Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.

    如果无法执行rails new app-name,则初始化新Rails应用的最佳方法是什么?

    如何只创建Gemfile?如果我有正确的Rails Gemfile,那么bundlerails new .应该有用......

1 个答案:

答案 0 :(得分:0)

运行rails new并且它大部分成功后(最终的bundle命令除外),没有必要再次生成Rails应用程序。

你好像做得对。您唯一的问题是无法安装单个gem。您应该再次尝试运行bundle install,如果仍然无效,请检查Gemfile中是否有source 'https://rubygems.org',可能rm -r .bundle删除任何本地Bundler设置。