【问题标题】:How to generate only a Gemfile in Rails?如何在 Rails 中只生成一个 Gemfile?
【发布时间】:2012-09-14 04:33:32
【问题描述】:

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

  1. 创建目录
  2. cd 目录
  3. 设置 ruby​​ 版本:rbenv local 1.9.3-p125(或其他版本)
  4. 镶嵌宝石: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

这之前有效,但这次我在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,那么 bundle 和 rails new . 应该可以工作...

【问题讨论】:

  • 问题似乎是 jquery-rails 的安装。您是否尝试再次运行捆绑软件?

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


【解决方案1】:

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

你似乎做对了一切。您唯一的问题是无法安装单个 gem。您应该再次尝试运行bundle install,如果仍然无法正常工作,请检查您的 Gemfile 中是否有 source 'https://rubygems.org',也许还有 rm -r .bundle 以删除任何本地 Bundler 设置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 2022-04-30
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 2019-10-30
    相关资源
    最近更新 更多