rails s - 权限被拒绝

rails s - Permission denied

我创建了一个 rails 应用程序,但我无法执行 rails serverrake routes,错误是:/home/charles/.rbenv/shims/rails: ligne 21: /root/.rbenv/libexec/rbenv: Permission non accordée

去 su 是可行的,但那样做并不好。

使用 visudo 我有这个,我当前的用户 charles 有用户权限:#

# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sb$

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
charles ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

ls -l 输出:

➜  alpha_blog git:(master) ✗ ls -l 
total 68
drwxr-xr-x 10 charles charles 4096 nov.  15 16:52 app
drwxr-xr-x  2 charles charles 4096 nov.  15 16:52 bin
drwxr-xr-x  5 charles charles 4096 nov.  15 16:52 config
-rw-r--r--  1 charles charles  130 nov.  15 16:52 config.ru
drwxr-xr-x  2 charles charles 4096 nov.  15 16:52 db
-rw-r--r--  1 charles charles 1974 nov.  15 16:52 Gemfile
-rw-r--r--  1 charles charles 4772 nov.  15 16:52 Gemfile.lock
drwxr-xr-x  4 charles charles 4096 nov.  15 16:52 lib
drwxr-xr-x  2 charles charles 4096 nov.  15 16:53 log
-rw-r--r--  1 charles charles   68 nov.  15 16:52 package.json
drwxr-xr-x  2 charles charles 4096 nov.  15 16:52 public
-rw-r--r--  1 charles charles  227 nov.  15 16:52 Rakefile
-rw-r--r--  1 charles charles  374 nov.  15 16:52 README.md
drwxr-xr-x  9 charles charles 4096 nov.  15 16:52 test
drwxr-xr-x  2 charles charles 4096 nov.  29 10:12 tmp
drwxr-xr-x  2 charles charles 4096 nov.  15 16:52 vendor

我创建了 sudo chown - R charles ./,其中 ./ 是我的 rails 目录。 我不知道我的用户和目录权限问题出在哪里,我不会像 su 一样执行这些命令,因为这不是一个好习惯。

通过 rbenv rehash

解决了问题