1

So I'm working on a project in which we are doing Vue.js front end with docker and then Ruby on Rails backend.

I'm trying to locally get everything set up but the remote repository has the following:

  • README.md
  • frontend
  • docker-compose.yml
  • backend

Cool so the frontend and backend are separate folders. So I did the following:

  1. Created local folder = project
  2. Git init
  3. Git clone bitbucket line of code. Which created = new_project folder with the above items
  4. CD into backend and attempted = rails new project

Which ends up with: Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first. Type 'rails' for help.

I removed the git init on the project folder and made new_project folder the init. Then removed the backend directory. And then tried to create a new directory with rails app here. Same issue.

How do I build out that app in a directory that is sibling to frontend?

Update: Went ahead and started from the Desktop and did: mkdir new_project > cd new_project > rails new_project. Same issue.

Exact commands I used:

MacBook-Pro-4:project jacob$ cd backend
MacBook-Pro-4:backend jacob$ rails new new_project
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails

You can then rerun your "rails" command.
mosers-MacBook-Pro-4:backend jacob.moore$ sudo gem install rails
ERROR:  Error installing rails:
    activesupport requires Ruby version >= 2.2.2.
MacBook-Pro-4:backend jacob$ rvm use 2.2.2
Done installing documentation for concurrent-ruby, thread_safe, tzinfo, i18n, activesupport, mini_portile2, nokogiri, rails-dom-testing, crass, loofah, rails-html-sanitizer, erubi, builder, actionview, rack, rack-test, actionpack, sprockets, sprockets-rails, bundler, method_source, thor, railties, mimemagic, marcel, arel, activemodel, activerecord, activestorage, websocket-extensions, websocket-driver, nio4r, actioncable, globalid, activejob, mini_mime, mail, actionmailer, rails after 68 seconds
39 gems installed
MacBook-Pro-4:backend jacob$ rails new new_project
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Type 'rails' for help.

Follow Up: I tried to straight up try and create an application on the Desktop and got the same issue. Pretty sure there's something in Desktop preventing this. Went to my Documents folder...no issue.

Jake
  • 1,328
  • 1
  • 21
  • 51
  • 4
    There are a bunch of odd things here. You should not have typed `git init`, if you're trying to clone the remote project, but that doesn't really matter as you're conflating several issues, Git is not related to your Rails problem. What is inside the `backend` directory already? – user229044 May 11 '18 at 16:51
  • Nothing. Which boggles the mind. – Jake May 11 '18 at 16:52
  • 1
    `rails new_project` is not a Rails command, can you use the editor to clearly reproduce the commands you're typing *and* the error messages? – user229044 May 11 '18 at 16:54
  • Indeed, is it `rails new_project` or `rails new project`? Very different outcomes. – Sergio Tulentsev May 11 '18 at 16:56
  • Sorry. I did do rails new new_project – Jake May 11 '18 at 16:57
  • git doesn't like empty folders. There must be *something* in the backend directory? – Ilion May 11 '18 at 18:23
  • "Pretty sure there's something in Desktop preventing this" - yeah. Look for anything resembling rails things in your `backend` and its parent folders, up to Desktop. config.ru, Rakefile, app, lib... I'm staring at rails code and for the moment, I have no idea where the exact check logic is. – Sergio Tulentsev May 12 '18 at 07:55
  • These might be helpful: https://stackoverflow.com/questions/17645041/why-doesnt-rails-s-work-from-the-app-directory, https://stackoverflow.com/questions/10023611/test-if-the-current-directory-is-inside-a-rails-project-bash?noredirect=1&lq=1 – Sergio Tulentsev May 12 '18 at 08:12

0 Answers0