无法在新安装的Rails上创建新应用程序

问题描述:

我试图在全新的Rails安装上创建一个新应用程序,它给了我一个'权限被拒绝',然后很多之前的其他东西根本不工作。无法在新安装的Rails上创建新应用程序

我试图寻找答案,但它似乎并没有很容易找到答案。这是我的终端是什么样子:

Zach-Beckers-Computer:rails_projects Zach$ rails new first_app 
     create 
/Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Permission denied - /rails_projects/first_app (Errno::EACCES) 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:205:in `each' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:51:in `block in invoke!' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `call' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `invoke_with_conflict_check' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:50:in `invoke!' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/actions.rb:95:in `action' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:15:in `empty_directory' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/railties-3.2.2/lib/rails/generators/app_base.rb:103:in `create_root' 
    from (eval):1:in `create_root' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/thor-0.14.6/lib/thor/base.rb:389:in `start' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/railties-3.2.2/lib/rails/commands/application.rb:38:in `<top (required)>' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/railties-3.2.2/lib/rails/cli.rb:15:in `<top (required)>' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/Zach/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' 
    from /Users/Zach/.rvm/gems/[email protected]/gems/railties-3.2.2/bin/rails:7:in `<top (required)>' 
    from /Users/Zach/.rvm/gems/[email protected]/bin/rails:19:in `load' 
    from /Users/Zach/.rvm/gems/[email protected]/bin/rails:19:in `<main>' 

我不知道我需要什么,或者我需要做的。我应该提到我在1岁的Macbook Pro上运行OSX Lion(10.7)。

对于您尝试创建Rails应用程序的目录,您没有写权限。确保该目录属于您的用户chown,并确保您拥有对该目录的写入权限chmod

看起来你正试图在根目录下创建一个rails应用程序,当你应该在你的“home”目录下。在OS X中是/ Users/Zach。这样做:

cd ~/ 
mkdir rails_projects 
cd rails_projects 
rails new first_app 
+0

谢谢,汤姆!这工作!我想知道为什么这个教程让我在根中创建它。由于我是这台计算机上唯一的用户/管理员,所以我始终没有想到,在根目录下创建的文件夹将无法写入访问权限。 – 2012-03-15 06:04:10

+0

是的,那将是一个奇怪的疏忽。你确定教程中提到'mkdir/rails_projects'而不是'mkdir rails_projects'吗?第一次尝试在根目录中创建,第二次尝试与当前路径相关,这通常是您的主目录。 – 2012-03-15 20:08:16