Ruby on Rails:为什么我必须使用sudo命令才能成功?

时间:2013-05-04 14:18:42

标签: ruby-on-rails ruby rubygems sudo refinerycms

我正在铁轨上学习ruby ...我已经能够在我的OSX(10.8.3)localhost上安装一个应用程序,但是除非我使用了sudo,否则大多数命令都会因为权限相关错误而失败,这是非常有问题的:< / p>

$ refinerycms ./

$ bundle install

$ bundle update

$ rails server

所有这些都没有sudo...而失败,我不知道为什么。这有点麻烦,但更重要的是,在设置过程中我似乎总是做错了。有谁知道我做错了什么以及如何解决它?

更新我怀疑这可能是相关的: (请注意,两者指向同一个地方。)

$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.4.0]
  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p194
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /usr/local/rvm/gems/ruby-1.9.3-p194
     - /usr/local/rvm/gems/ruby-1.9.3-p194@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/


$ sudo gem environment
Password:
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.4.0]
  - INSTALLATION DIRECTORY: /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1
     - /Users/ESL/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

这可能与~/.rvm不存在的事实有关,也可能与此无关。它似乎不存在.rvm

更新2 我对rails应用程序了解不多,但我注意到某些文件似乎归系统所有,而不是我的用户。这是正常的吗?

更新3 我的预感是我的所有宝石都与root用户相关联,而不是我的用户,这可以解释为什么每次我尝试做事情时都会遇到权限错误。所以我尝试重新安装rvm作为用户......

$ \curl -L https://get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   184  100   184    0     0    192      0 --:--:-- --:--:-- --:--:--   223
100 13641  100 13641    0     0   9060      0  0:00:01  0:00:01 --:--:--  9060
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   124  100   124    0     0    381      0 --:--:-- --:--:-- --:--:--   475
100 3263k  100 3263k    0     0   536k      0  0:00:06  0:00:06 --:--:--  615k

Upgrading the RVM installation in /usr/local/rvm/
    RVM PATH line found in /Users/ESL/.bashrc /Users/ESL/.zshrc.
    RVM sourcing line found in /Users/ESL/.bash_profile /Users/ESL/.zprofile.

Upgrade Notes:


  * WARNING: you have 'rvm_configure_env' in /etc/rvmrc, run the following to fix:

      sudo sed -i'' -e "/rvm_configure_env=.*\/opt\/sm/d" /etc/rvmrc
      rvm autolibs smf

  * No new notes to display.

# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues run 'rvm requirements' or read 'rvm notes'

Upgrade of RVM in /usr/local/rvm/ is complete.

#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and
#   more enjoyable!!!
#
# ~Wayne

It seems to have worked, but it looks to me like it keeps landing in the root instead of /Users/ME. Am I onto something?

更新

$ \curl -L https://get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   184  100   184    0     0    124      0  0:00:01  0:00:01 --:--:--   143
100 13641  100 13641    0     0   6907      0  0:00:01  0:00:01 --:--:--  6907
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   124  100   124    0     0    561      0 --:--:-- --:--:-- --:--:--   712
100 3263k  100 3263k    0     0   767k      0  0:00:04  0:00:04 --:--:--  907k

Installing RVM to /usr/local/rvm/
    RVM PATH line found in /Users/ESL/.bashrc /Users/ESL/.zshrc.
    RVM sourcing line found in /Users/ESL/.bash_profile /Users/ESL/.zprofile.

# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues run 'rvm requirements' or read 'rvm notes'

Installation of RVM in /usr/local/rvm/ is almost complete:

  * First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and
#   more enjoyable!!!
#
# ~Wayne

1 个答案:

答案 0 :(得分:1)

您错误地安装了RVM,这很容易。 “这通常是因为人们以root身份执行安装,而不是从非特权用户帐户执行安装指令。”我建议用sudo rvm implode完全删除RVM,然后在单用户模式下再次安装它。像你一样奔跑,而不是根,而不是sudo:

\curl -L https://get.rvm.io | bash -s stable