-1

I tried creating a new Rails app, and got this error:

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

I tried running bundle and got the same error.

What am I doing wrong?

David Hempy
  • 5,373
  • 2
  • 40
  • 68

2 Answers2

1

Just leave off the bundle exec part of the command:

% 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 new my_app is probably the only command in the Rails environment that can't run under 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. 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:

"rails" new my_app
      create
      create  README.md
      create  Rakefile
      (etc.)
David Hempy
  • 5,373
  • 2
  • 40
  • 68
1

what about :

  • rails new app_name
  • cd app_name
  • bundle
Maxime
  • 53
  • 4