Rails 求助,也许是 linux 的问题

shangrenzhidao · 2013年11月08日 · 最后由 Rei 回复于 2013年11月14日 · 2356 次阅读

我在进入 ubuntu 后每次都要输入 source /etc/profile.d/rvm.sh 系统才能识别我 ruby rails rvm 这些命令,请问是不是我哪里没有设置?

echo "source /etc/profile.d/rvm.sh " >> ~/.bashrc

#1 楼 @song940 这样就可以不需要打开那个文件修改么

#1 楼 @song940 重启了,还是不行

试试放到.bash_profile

#4 楼 @imlcl 我没有这个文件呀

#1 楼 @song940 +1 echo "source /etc/profile.d/rvm.sh " >> .bashrc #5 楼 @chunlea +1 参考 http://rvm.io/integration/gnome-terminal

这个问题属于 RVM 的问题,而不是 Rails 的

最简单的方案就是 echo "source /etc/profile.d/rvm.sh " >> ~/.bashrc

如果你用的是 bash(估计你用的一定是 bash) 那么你可以看看帮助文档 man bash INVOCATION 部分 了解一下 bash 和 ~/.bashrc 和 .bash_profile 的关系

#9 楼 @ery 但是如果我切换到 root 用户这个就不行了,还需要手动输入一次 source ...

普通用户和 root 的 terminal 启动配置是写在不同文件里的,用户在 ~/.bashrc,root 好像是在另一个文件里,具体的股沟

干嘛要用 root 用户搞这种事情呢??多危险啊

#14 楼 @AlphaLiu 嗯,搭建环境时候有不会出现权限这样的问题

Multi-User:

The rvm function will be automatically configured for every user on the system if you install with sudo. This is accomplished by loading /etc/profile.d/rvm.sh on login. Most Linux distributions default to parsing /etc/profile which contains the logic to load all files residing in the /etc/profile.d/ directory. Once you have added the users you want to be able to use RVM to the rvm group, those users MUST log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time.

https://rvm.io/rvm/install

#16 楼 @Rei 我安装的时候就是在 root 下,是不是在 root 下用不用 sudo 前缀都可以呢?

#17 楼 @shangrenzhidao 用 root 安装不是装在 root 下,而是装成 multi-user 模式。我现在都用 single-user 模式了,记不太清楚要怎么弄。

root 是个特殊的用户,如果搞不清楚的话还是不要用,不过你可以趁机搞明白 root 和 sudo 跟 Linux 用户权限的问题。

#18 楼 @Rei 谢谢 我再研究研究

Note: The Multi-User install instructions must be prefixed with the 'sudo' command. However, once the install is complete, and the instructions to add users to the rvm group is followed, the use of either sudo or rvmsudo is no longer required. The 'sudo' command is only to temporarily elevate privileges so the installer can complete it's work. If you need to use 'sudo' or 'rvmsudo' after the install is complete, some part of the install directions were not properly followed. This usually is because people execute the install as root, rather than executing the installation instructions from a non-privileged user account.

这里说用 sudo 安装跟用 root 安装还不一样,root 会导致一些问题。

正常 multi-user 模式是普通用户用 sudo 安装,然后将用户加到 rvm 组,之后不需要 sudo 或 rvmsudo。

我建议是用 single-user 模式。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号