在ubuntu 14.04上为所有用户全局设置ruby [英] Set up ruby globally for all users on ubuntu 14.04

查看:186
本文介绍了在ubuntu 14.04上为所有用户全局设置ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以这种方式安装ruby,使其对ubuntu 14.04服务器上的所有用户可见

嗯,我试图使ruby -v对所有用户可见,但失败了.

ugh I'm trying to make ruby -v visible for all users and I failed.

问题2: 我可以更改权限吗?如果是这样,怎么办?如果没有,我该如何卸载其他安装?

Question 2: Can I just change permissions? if so, how? if not, how would I uninstall the other installation?

我有2个主要用户: ubuntu(默认)和jenkins(第二)

I have 2 main users: ubuntu (default) and jenkins(secondary)

我按照以下 Tut 中的rbenv进行设置:

I followed this set up for rbenv from this Tut:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.1.5
rbenv global 2.1.5
ruby -v

但是我是在默认用户名下完成的

But I did it under the default user

+whoami
ubuntu
+ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]

如果我切换用户:

 +sudo su - jenkins
 +whoami
 jenkins

 +ruby -v
 The program 'ruby' can be found in the following packages:
 * ruby
 * ruby1.8
 Ask your administrator to install one of them

关于权限,我是一个超级菜鸟,所以希望您能握住我的手

最后,我试图让詹金斯(Jenkins)看到红宝石进行建造.

In the end I'm trying to get Jenkins to see ruby for a build.

我的詹金斯工作失败了,因为它找不到红宝石,因为它找不到红宝石:c

My Jenkins Job is failing because it cant find sass because it can't find ruby :c

4mRunning "test:client" (test) task[24m

[4mRunning "clean:server" (clean) task[24m

[4mRunning "env:all" (env) task[24m

[4mRunning "injector:sass" (injector) task[24m
[90mMissing option `template`, using `dest` as template instead[39m
Injecting [32mscss[39m files [90m(3 files)[39m
[32m>> [39mNothing changed

[4mRunning "concurrent:test" (concurrent) task[24m
    [33mWarning: [4mRunning "sass:server" (sass) task[24m
    [33mWarning: 
    You need to have Ruby and Sass installed and in your PATH for this task to work.
    More info: https://github.com/gruntjs/grunt-contrib-sass
     Use --force to continue.[39m

更新: 所以我在sudo su - jenkins下重新安装了rbenv,一切正常,但是有没有办法将rbenv作为全局用户安装,或者这不是rbenv应该工作的方式吗?

UPDATE: So I reinstalled rbenv under sudo su - jenkins and everything works but is there a way to still install rbenv as a global user or is this not how rbenv is suppose to work??

更新* 2: 我的第一次更新没有用.这一次我是怎么做到的.

UPDATE * 2: My first update didnt work. heres how I did it this time.

sudo su -
sudo apt-get install ruby-full
gem install ...

推荐答案

您的更新* 2处在正确的轨道上.

You're on the right track with your update * 2.

如果要为所有用户安装某些软件,请使用

If you want to install something for all users, use

apt-get install

rbenv主要用于必须在不同的ruby环境之间切换的情况(例如,开发多个应用程序,每个应用程序都需要安装自己的,可能有冲突的一组依赖关系)

rbenv is mainly useful if you have to switch between different ruby environments (e.g., you develop multiple apps each need their own, possibly conflicting, set of dependencies installed)

因此回答"Q1如何以这样的方式安装ruby,使其对我的ubuntu 14.04服务器上的所有用户可见"

So to answer "Q1 How can I install ruby, in such a way, that it's visible to all users on my ubuntu 14.04 server"

以特权用户身份(root或可能为ubuntu)运行

as a privileged user (root or possibly ubuntu) run

apt-get install ruby-full

问题2-4:我可以只更改权限吗?如果是这样,怎么办?如果没有,我该如何卸载其他安装?

Questions 2-4: Can I just change permissions? if so, how? if not, how would I uninstall the other installation?

我可以只更改权限吗?

Can I just change permissions?

这不仅仅是权限问题;这是一个PATH和权限问题.作为jenkins用户,您可以

This is not just a permissions problem; it's a PATH and permissions problem. As the jenkins user you can do

export PATH="~ubuntu/.rbenv/plugins/ruby-build/bin:$PATH"

export PATH="~ubuntu/.rbenv/plugins/ruby-build/bin:$PATH"

ubuntu用户的.rbenv添加到您的路径.但是,最好为jenkins用户设置rbenv. jenkins用户可能没有权限读取,chdir和执行ubuntu用户的主目录及其.rbenv子目录

to add the ubuntu user's .rbenv to your path. But you probably would be better off setting up rbenv for the jenkins user. The jenkins user might not have permissions to read, chdir, and execute the ubuntu user's home directory and its .rbenv subdirectory

如何(我可以更改权限)

How (can I change permissions)

您可以使用chmod更改权限.但是更改权限可以轻松破坏您的系统.与使用木材或纸张一样,最好找到一种方法来使用系统的纹理(不必更改权限),而不是反对系统的纹理.

You can change permissions with chmod. But changing permissions can easily screw up your system. As with wood or paper, it's better to find a way to work with the grain of the system (not having to change permissions) rather than against the grain of the system.

我将如何卸载其他安装

How would I uninstall the other installation

sudo rm -rf ~ubuntu/.rbenv

sudo rm -rf ~ubuntu/.rbenv

如果您没有系统管理指南,则可能需要查阅一下.多年前,我从这本书的早期版本中学到了:< http://www.amazon.ca/Essential-System-Administration -Tools-Techniques/dp/0596003439 >

You may want to check out a good guide to system administration if you don't have one. I learned, years ago, from an earlier edition of this book: < http://www.amazon.ca/Essential-System-Administration-Tools-Techniques/dp/0596003439 >

这篇关于在ubuntu 14.04上为所有用户全局设置ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆