【问题标题】:`rails new my_app` returns "Could not locate Gemfile or .bundle/ directory"`rails new my_app` 返回“找不到 Gemfile 或 .bundle/ 目录”
【发布时间】:2020-03-05 13:34:34
【问题描述】:

我尝试创建一个新的 Rails 应用程序,但收到此错误:

% bundle exec rails new my_app
Could not locate Gemfile or .bundle/ directory

我尝试运行bundle 并得到同样的错误。

我做错了什么?

【问题讨论】:

    标签: ruby-on-rails bundle gemfile


    【解决方案1】:

    只需去掉命令的bundle exec 部分:

    % bundle exec rails new my_app 
    Could not locate Gemfile or .bundle/ directory
    
    % rails new my_app
          create
          create  README.md
          create  Rakefile
          create  .ruby-version
          create  config.ru
          create  .gitignore
          create  Gemfile
             run  git init from "."
          (etc.)
    

    在生成新的 Rails 应用程序的情况下(作为一名全职 Rails 开发人员,我在几年内只做过 3-4 次),还没有 Gemfile……就像错误提示的那样。 rails new my_app 可能是 Rails 环境中唯一不能在 bundler 下运行的命令。

    如果您的 shell 中有 alias rails=bundle exec rails,或者您的手指刚刚被训练为始终为 rails 命令键入 bundle exec,这可能是一个特殊的问题。在这种情况下,您可以删除该别名 (unalias rails),但最好通过将其括在引号中来绕过该别名:

    "rails" new my_app
          create
          create  README.md
          create  Rakefile
          (etc.)
    

    【讨论】:

      【解决方案2】:

      怎么样:

      • rails new app_name
      • cd app_name
      • 捆绑

      【讨论】:

      • 问题在于,bundle exec 在rails new 命令上。
      • 这就是为什么我建议删除 bundle exec
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 2019-01-04
      • 1970-01-01
      • 2015-11-09
      • 1970-01-01
      • 2020-08-25
      • 1970-01-01
      相关资源
      最近更新 更多