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

时间:2020-03-05 13:34:34

标签: ruby-on-rails bundle gemfile

我尝试创建一个新的Rails应用,但出现此错误:

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

我尝试运行bundle并遇到相同的错误。

我在做什么错了?

2 个答案:

答案 0 :(得分:1)

有关:

  • 使用新的应用名称
  • cd app_name
  • 捆绑包

答案 1 :(得分:0)

只需省略命令的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应用程序的情况下(我几年来只做过3-4次Rails专职开发人员),还没有Gemfile ...就像错误提示一样。 rails new my_app可能是Rails环境中不能在捆绑程序下运行的唯一命令。

如果您的外壳中有alias rails=bundle exec rails,或者您的手指仅受过训练,总是要为Rails命令键入bundle exec,则这可能是一个特殊的陷阱。在这种情况下,您可以删除该别名(unalias rails),但是最好一次绕过别名,方法是将其用引号引起来:

"rails" new my_app
      create
      create  README.md
      create  Rakefile
      (etc.)
相关问题