accidentally created a rails app in the home folder

115 views
Skip to first unread message

mark ronay

unread,
May 31, 2013, 6:28:06 PM5/31/13
to rubyonra...@googlegroups.com
Im a new user - I just installed rails, following directions here:
http://rubyonrails.org/download
however, when it came time to make a rails new path/etc/etc I get this
message:
Can't initialize a new Rails application within the directory of
another, please change to a non-Rails directory first.
The only complication during the download was that I had to upgrade from
version 1.8.6 to 1.9.3, which I did after installing rails. Otherwise
Ive done nothing but follow the very simple directions.
I found this very helpful thread http://www.ruby-forum.com/topic/1780147
but when the output of ls -l shows just my usual directories. Any help
is greatly appreciated.

--
Posted via http://www.ruby-forum.com/.

Hassan Schroeder

unread,
May 31, 2013, 6:49:31 PM5/31/13
to rubyonra...@googlegroups.com
On Fri, May 31, 2013 at 3:28 PM, mark ronay <li...@ruby-forum.com> wrote:
> Im a new user - I just installed rails, following directions here:
> http://rubyonrails.org/download
> however, when it came time to make a rails new path/etc/etc I get this
> message:
> Can't initialize a new Rails application within the directory of
> another, please change to a non-Rails directory first.

So, what happens if you make a new directory, cd to it, and run your
`rails new blah` command?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

mark ronay

unread,
May 31, 2013, 6:54:08 PM5/31/13
to rubyonra...@googlegroups.com
exact same thing

Hassan Schroeder

unread,
May 31, 2013, 7:22:19 PM5/31/13
to rubyonra...@googlegroups.com
On Fri, May 31, 2013 at 3:54 PM, mark ronay <li...@ruby-forum.com> wrote:
> exact same thing

In an empty directory? Then I'd say you have serious problems.

> The only complication during the download was that I had to
> upgrade from version 1.8.6 to 1.9.3, which I did after installing rails.

Wait, *after* installing Rails? That, in retrospect, sounds bad. What
OS/platform are you on?

And what do you get from the following commands:
ruby -v
rails -v
gem -v

mark ronay

unread,
May 31, 2013, 7:49:14 PM5/31/13
to rubyonra...@googlegroups.com
ruby -v gives ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux]
rails -v gives Rails 3.2.13
gem -v gives 1.8.25

Im running ubuntu. I had ruby 1.8.6. I installed gem but it gave an
error when I was trying to get rails through gem, bc i had the old
version of ruby. I got rvm, updated to 1.9.3 and then reinstalled rails.

It does indeed give the same " Can't initialize a new Rails application
within the directory of another, please change to a non-Rails directory
first" when Im in an empty directory I made from home.

Thank you for your help by the way.

Rick

unread,
May 31, 2013, 8:26:03 PM5/31/13
to rubyonra...@googlegroups.com
What is the command you are using to create a new rails app?  Just to be sure, type the command into a terminal window and copy / paste the command you typed and the output from rails.

Hassan Schroeder

unread,
May 31, 2013, 8:38:01 PM5/31/13
to rubyonra...@googlegroups.com
On Fri, May 31, 2013 at 4:49 PM, mark ronay <li...@ruby-forum.com> wrote:
> ruby -v gives ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux]
> rails -v gives Rails 3.2.13
> gem -v gives 1.8.25

Those seem reasonable, though the result doesn't :-/

Given that you're just starting, I'd be inclined to totally remove rvm
(rvm implode), make sure that your old system ruby has no trace
of rails or related gems, and then reinstall rvm, 1.9.3, and rails.

Slash and burn, but ... with a quick look at the source, I don't see
how you're getting that message...

Rick

unread,
May 31, 2013, 9:09:16 PM5/31/13
to rubyonra...@googlegroups.com
There are (at least) two executable ruby scripts named "rails".  The first is found in your typical search path and should be the one that gets called when you type "rails new my_app".  The second is found, after creating your new application "my_app", in the directory "my_app/script" (rails version 3) or "my_app/bin" (rails version 4).

These ruby scripts named "rails" are not the same and, if you call the second with the "new my_app" arguments, "rails" will assume you are running inside an existing application and hurl error chunks at you.

Do this

1) type the command "which rails" and you will see the full path to what your current shell assumes to be the true rails command. 

i.e. on my system
555 > which rails
/opt/local/bin/rails
 556 >

2) type the command "wc -l `which rails`" -- if you can't figure out the quoting just use the result of step 1.  i.e. on my system "which /opt/local/bin/rails"

you should see a result that is somewhere around 23 (lines) but i'm thinking you'll see 6.  the first number is the correct system wide rails script that will let you create a new app, the second number is the rails script that is placed into "my_app/script" (or "my_app/bin") and will be used when you "rails generate ..." or other such inside your new application directory structure.

just to beat this horse to death, here's what i get when, in my home directory, i call an application (6 line) rails with new...

561 > binky/script/rails new boffo

Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Type 'rails' for help.
 562 >

look familiar?

Rick

unread,
May 31, 2013, 9:34:27 PM5/31/13
to rubyonra...@googlegroups.com
for what it's worth, the error message is generated in the file: gems/railties-3.2.13/lib/rails/commands.rb

mark ronay

unread,
May 31, 2013, 11:13:34 PM5/31/13
to rubyonra...@googlegroups.com
Hassan Schroeder wrote in post #1110852:
Im starting to lean that way, thanks again.

mark ronay

unread,
May 31, 2013, 11:28:19 PM5/31/13
to rubyonra...@googlegroups.com
Hi Rick,
thanks! I tried carrying out those instructions: heres what i got -
mwr@mwr-Ubuntu:/home$ which rails
/home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails


mwr@mwr-Ubuntu:/home$ which
/home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails
/home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails

I suppose im having trouble with step 2 of your directions. However its
nice to have a kind of explanation of whats going on. Again, excuse my
illiteracy on this, but it look like maybe i do have rails installed in
my home directory?

**just discovered by accident I can do this:
mwr@mwr-Ubuntu:/home$ which
/home/mwr/.rvm.gems/ruby-1.9.3-p429/bin/rails
mwr@mwr-Ubuntu:/home$ wc -l 'which rails'
wc: which rails: No such file or directory
mwr@mwr-Ubuntu:/home$ cd ..
mwr@mwr-Ubuntu:/$ which rails
/home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails
mwr@mwr-Ubuntu:/$ which /home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails
/home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails
mwr@mwr-Ubuntu:/$ rails new path/here
create
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:247:in
`mkdir': Permission denied - /path (Errno::EACCES)
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:247:in
`fu_mkdir'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:221:in
`block (2 levels) in mkdir_p'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:219:in
`reverse_each'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:219:in
`block in mkdir_p'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:205:in
`each'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:205:in
`mkdir_p'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:51:in
`block in invoke!'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:117:in
`call'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:117:in
`invoke_with_conflict_check'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:50:in
`invoke!'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/actions.rb:95:in
`action'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/actions/empty_directory.rb:15:in
`empty_directory'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/generators/app_base.rb:103:in
`create_root'
from (eval):1:in `create_root'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/command.rb:27:in
`run'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/invocation.rb:120:in
`invoke_command'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/invocation.rb:127:in
`block in invoke_all'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/invocation.rb:127:in
`each'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/invocation.rb:127:in
`map'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/invocation.rb:127:in
`invoke_all'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/group.rb:233:in
`dispatch'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/thor-0.18.1/lib/thor/base.rb:439:in
`start'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/commands/application.rb:38:in
`<top (required)>'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/lib/rails/cli.rb:15:in
`<top (required)>'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
from
/home/mwr/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
from
/home/mwr/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.13/bin/rails:7:in
`<top (required)>'
from /home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails:19:in `load'
from /home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails:19:in `<main>'
from /home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/ruby_noexec_wrapper:14:in
`eval'
from /home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/ruby_noexec_wrapper:14:in
`<main>'
mwr@mwr-Ubuntu:/$ ls
bin dev initrd.img lib64 mnt root selinux tmp
vmlinuz
boot etc initrd.img.old lost+found opt run srv usr
vmlinuz.old
cdrom home lib media proc sbin sys var

Colin Law

unread,
Jun 1, 2013, 3:43:41 AM6/1/13
to rubyonra...@googlegroups.com
On 31 May 2013 23:28, mark ronay <li...@ruby-forum.com> wrote:
> Im a new user - I just installed rails, following directions here:
> http://rubyonrails.org/download
> however, when it came time to make a rails new path/etc/etc I get this
> message:
> Can't initialize a new Rails application within the directory of
> another, please change to a non-Rails directory first.

Rather than specifying a complex path to the new application (my guess
is that you have already created a rails app in path/etc/etc, so it
will not let you create a new one there) just cd to, for example your
home directory using
cd ~
then create an app called, for example, myapp
rails new myapp

Colin


> The only complication during the download was that I had to upgrade from
> version 1.8.6 to 1.9.3, which I did after installing rails. Otherwise
> Ive done nothing but follow the very simple directions.
> I found this very helpful thread http://www.ruby-forum.com/topic/1780147
> but when the output of ls -l shows just my usual directories. Any help
> is greatly appreciated.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/423d62f3592cef90d328e7442490793e%40ruby-forum.com?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Rick

unread,
Jun 1, 2013, 7:21:57 AM6/1/13
to rubyonra...@googlegroups.com
i now see i misstyped the instructions to step 2.  here it is, corrected

2) type the command "wc -l `which rails`" -- if you can't figure out the quoting just use the result of step 1.  i.e. on my system "wc -l /opt/local/bin/rails"

the idea is to use the wc command to get the number of lined in the rails script you are calling by default.  the quoting used in wc -l `which rails` an open single quote - on a mac keyboard it's found on the key to the left of number one.  it's a bit of unix shell magic that causes the quoted text to be evalulated as a command and the results to be handed off the the wc -l command as argument(s).  thus, on my system, it becomes wc -l /opt/local/bin/rails.

in your case wc -l `which rails` would be equivalent to wc -l /home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails and i'll be surprised if the result is much greater than 6.  i don't use rvm so cannot help you troubleshoot rvm specific errors.  i can say that you don't want to be creating your new app anywhere inside the .../.rvm/... directory tree.  think of this as a managed software repository - anything that gets changed there is done through rvm.  make yourself a working directory, cd there and run the rails new command.  something like:

mkdir /home/mwr/RailsApps

cd /home/mwr/RailsApps
rails new my_new_app

mark ronay

unread,
Jun 1, 2013, 1:05:16 PM6/1/13
to rubyonra...@googlegroups.com
Alright, now its working kind of! After restarting the computer and
using which rails i get the much more sensible looking path *
/usr/local/bin/rails *
running wc -l `which path` I get * 19 /usr/local/bin/rails *

so now navigating above my home directory I am able to use rails new
like so: * mwr@mwr-Ubuntu:/$ sudo rails new blah/here * and it seems to
work.

now - i cant access my localhost, but thats a separate issue i think i
can work out.

Thanks everyone for your help!

Colin Law

unread,
Jun 1, 2013, 3:57:29 PM6/1/13
to rubyonra...@googlegroups.com
On 1 June 2013 18:05, mark ronay <li...@ruby-forum.com> wrote:
> Alright, now its working kind of! After restarting the computer and
> using which rails i get the much more sensible looking path *
> /usr/local/bin/rails *
> running wc -l `which path` I get * 19 /usr/local/bin/rails *
>
> so now navigating above my home directory I am able to use rails new
> like so: * mwr@mwr-Ubuntu:/$ sudo rails new blah/here * and it seems to
> work.

Don't use sudo, you will get the wrong ownership on the files

Also I recommend using rvm to install ruby and rails.

>
> now - i cant access my localhost, but thats a separate issue i think i
> can work out.

Possibly due to using sudo when creating the app.

Colin

mark ronay

unread,
Jun 4, 2013, 2:24:15 AM6/4/13
to rubyonra...@googlegroups.com
just an update/follow up. I can successfully run rails and get a rails
server going on my localhost. However, my paths remain totally messed up
and I dont know why. I get the error I originally posted about anywhere
I go (and I am completely certain I am not inside a path that already
has a rails app in it) except, if I go above my home file into my what i
call my root file, it looks like this.
mwr@mwr-Ubuntu:/home$ cd ..
mwr@mwr-Ubuntu:/$ cd ..
mwr@mwr-Ubuntu:/$ ls
app cdrom initrd.img lost+found proc selinux usr
bin dev initrd.img.old media root srv var
blah etc lib mnt run sys vmlinuz
boot home lib64 opt sbin tmp vmlinuz.old
mwr@mwr-Ubuntu:/$

my understanding is this cant really be right. To get a rails project
working I have to type sudo for every single command i give, from mkdir
to rails new app etc. But there is nowhere else in my system where i can
run rails new and this was true from the very first time I tried to run
it.
I attempted to uninstall rails, but even though it seemed I did, running
'which rails' would always yield a result. I wound up reinstalling
anyways.

maybe this is just how it works? or have I made some sort of correctable
mistake?

Colin Law

unread,
Jun 4, 2013, 2:35:16 AM6/4/13
to rubyonra...@googlegroups.com
That is not how it should work. I suggest starting again using rvm to
install rails. You don't actually need to get rid of anything you have
already installed but it will do no harm to do so. The rvm install
should take precedence over the existing messed up installation.

Colin

mark ronay

unread,
Jun 4, 2013, 1:33:03 PM6/4/13
to rubyonra...@googlegroups.com
well, i tried rvm implode and a fresh install using these directions:
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

still same problem:
mwr@mwr-Ubuntu:~$ ls
app db Documents log Projects script tmp
build Desktop Downloads Music Public Templates vendor
config doc lib Pictures public test Videos
mwr@mwr-Ubuntu:~$ rails new blargh/here
Can't initialize a new Rails application within the directory of
another, please change to a non-Rails directory first.
Type 'rails' for help.
mwr@mwr-Ubuntu:~$ which rails
/home/mwr/.rvm/gems/ruby-1.9.3-p429/bin/rails
mwr@mwr-Ubuntu:~$ rails new blog
Can't initialize a new Rails application within the directory of
another, please change to a non-Rails directory first.
Type 'rails' for help.
mwr@mwr-Ubuntu:~$

Im at a loss, going to try to post to ubuntu specific forums. Thanks
everyone for your help and if I fix it I will post here in case it helps
someone else.

Hassan Schroeder

unread,
Jun 4, 2013, 1:42:27 PM6/4/13
to rubyonra...@googlegroups.com
On Tue, Jun 4, 2013 at 10:33 AM, mark ronay <li...@ruby-forum.com> wrote:

> still same problem:
> mwr@mwr-Ubuntu:~$ ls
> app db Documents log Projects script tmp
> build Desktop Downloads Music Public Templates vendor
> config doc lib Pictures public test Videos
> mwr@mwr-Ubuntu:~$ rails new blargh/here
> Can't initialize a new Rails application within the directory of
> another, please change to a non-Rails directory first.

> Im at a loss

?? Your `ls` shows the directories of a standard Rails app, so the
message is perfectly understandable.

If you don't want them there, why don't you *remove* them?

mark ronay

unread,
Jun 4, 2013, 1:54:55 PM6/4/13
to rubyonra...@googlegroups.com
Hassan Schroeder wrote in post #1111345:
:D now i feel really stupid. Problem solved!! I really should have
opened with the ls, Im sure I dont know how those get there and didnt
know how to recognize them. Thank you all again.

Tamara Temple

unread,
Jun 5, 2013, 6:16:54 PM6/5/13
to rubyonra...@googlegroups.com
Is there some reason you can't move or delete the files you created?
Does this Rails app you built initially in your home directory have to
be there?

mark ronay

unread,
Jun 5, 2013, 6:46:27 PM6/5/13
to rubyonra...@googlegroups.com
Tamara Temple wrote in post #1111488:
> mark ronay <li...@ruby-forum.com> wrote:
>> another, please change to a non-Rails directory first.
>> everyone for your help and if I fix it I will post here in case it helps
>> someone else.
>
>
> Is there some reason you can't move or delete the files you created?
> Does this Rails app you built initially in your home directory have to
> be there?


Oh I did delete them and everything is going great now. I was unaware
that they had been created in my home directory, as I had not ever run
*rails new* successfully and didnt know what to look for. So the whole
thread is basically me not knowing I had rails files in my home
directory. I assume they got there during the install process somehow.

Tamara Temple

unread,
Jun 5, 2013, 9:11:43 PM6/5/13
to rubyonra...@googlegroups.com, mark ronay
mark ronay <li...@ruby-forum.com> wrote:
> Oh I did delete them and everything is going great now.

Yay!! \o/

Welcome to Rails!!

> I was unaware
> that they had been created in my home directory, as I had not ever run
> *rails new* successfully and didnt know what to look for. So the whole
> thread is basically me not knowing I had rails files in my home
> directory. I assume they got there during the install process somehow.

Happens. I have stories....
Reply all
Reply to author
Forward
0 new messages