生成rails控制器时权限被拒绝

时间:2015-04-22 19:09:55

标签: ruby-on-rails linux ubuntu ruby-on-rails-4

我正在使用VPS和ubuntu试图让rails生成一个控制器,但我不断得到下面列出的一个奇怪的权限错误,当我尝试使用“sudo rails generate”时,它说命令无法找到,有任何想法吗?

    /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:252:in `mkdir': Permission denied @ dir_s_mkdir - /run/user/0/spring (Errno::EACCES)
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:252:in `fu_mkdir'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:226:in `block (2 levels) in mkdir_p'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:224:in `reverse_each'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:224:in `block in mkdir_p'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:210:in `each'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:210:in `mkdir_p'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/env.rb:37:in `tmp_path'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/env.rb:54:in `pidfile_path'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/env.rb:69:in `server_running?'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/run.rb:25:in `call'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/command.rb:7:in `call'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/rails.rb:24:in `call'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client/command.rb:7:in `call'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/client.rb:26:in `run'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/bin/spring:48:in `<top (required)>'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/binstub.rb:11:in `load'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.4/lib/spring/binstub.rb:11:in `<top (required)>'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/katgus/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/katgus/appname/bin/spring:13:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

1 个答案:

答案 0 :(得分:0)

使用rbenv为/home/katgus/.rbenv上的用户安装了命令rails。当您运行"sudo rails generate"时,您没有使用您的用户环境。然后你就有了这个错误。

最好的方法是修复权限问题,您的用户可以创建dirs。