权限被拒绝@ dir_s_mkdir - / run / user / gui / spring(Errno :: EACCES)

时间:2015-09-22 05:02:38

标签: ruby-on-rails ruby-on-rails-4 ruby-on-rails-3.2

我在打开时遇到此问题 - > rails console

[chitra@localhost todo_app]$ rails c
/home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:252:in `mkdir': Permission denied @ dir_s_mkdir - /run/user/gui/spring (Errno::EACCES)
    from /home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:252:in `fu_mkdir'
    from /home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:226:in `block (2 levels) in mkdir_p'
    from /home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:224:in `reverse_each'
    from /home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:224:in `block in mkdir_p'
    from /home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:210:in `each'
    from /home/chitra/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:210:in `mkdir_p'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/env.rb:37:in `tmp_path'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/env.rb:54:in `pidfile_path'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/env.rb:69:in `server_running?'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/client/run.rb:25:in `call'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/client/command.rb:7:in `call'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/client/rails.rb:24:in `call'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/client/command.rb:7:in `call'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/client.rb:28:in `run'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/bin/spring:49:in `<top (required)>'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/binstub.rb:11:in `load'
    from /home/chitra/.rvm/gems/ruby-2.2.0@todo/gems/spring-1.4.0/lib/spring/binstub.rb:11:in `<top (required)>'
    from /opt/projects/todo_app/bin/spring:13:in `require'
    from /opt/projects/todo_app/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

我正在使用ruby版本2.2.0p0和rails 4.2。 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:4)

以下是抛出错误的代码:

# File 'lib/spring/env.rb', line 35

def tmp_path
  path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring"))
  FileUtils.mkdir_p(path) unless path.exist?
  path
end

您似乎已将XDG_RUNTIME_DIR设置为/run/user/gui/,但服务器对该目录没有写入权限。因此,您可以授予对该目录的访问权限,也可以通过键入XDG_RUNTIME_DIR

取消设置unset XDG_RUNTIME_DIR