简体   繁体   English

`rails new my_app` 返回“找不到 Gemfile 或 .bundle/ 目录”

[英]`rails new my_app` returns "Could not locate Gemfile or .bundle/ directory"

I tried creating a new Rails app, and got this error:我尝试创建一个新的 Rails 应用程序,并收到此错误:

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

I tried running bundle and got the same error.我尝试运行bundle并得到相同的错误。

What am I doing wrong?我究竟做错了什么?

Just leave off the bundle exec part of the command:只需离开命令的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.)

In the case of generating a new rails app (something that I've only done 3-4 times in several years as a full-time Rails developer), there is no Gemfile yet...just like the error suggests.在生成新的 Rails 应用程序的情况下(作为一名全职 Rails 开发人员,我在几年内只做过 3-4 次),还没有 Gemfile ......就像错误所暗示的那样。 rails new my_app is probably the only command in the Rails environment that can't run under bundler. rails new my_app可能是 Rails 环境中唯一不能在 bundler 下运行的命令。

This may be a particular gotcha if you've got an alias rails=bundle exec rails in your shell, or if your fingers are just trained to always type bundle exec for rails commands.如果你的 shell 中有一个alias rails=bundle exec rails ,或者你的手指只是被训练为总是为 rails 命令键入bundle exec ,这可能是一个特殊的问题。 In this case, you could remove that alias ( unalias rails ), but it's probably better to bypass the alias just this once by enclosing it in quotes:在这种情况下,您可以删除该别名( unalias rails ),但最好通过将其括在引号中来绕过别名一次:

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

what about :关于什么 :

  • rails new app_name rails 新 app_name
  • cd app_name cd app_name
  • bundle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM