Set up ruby globally for all users on ubuntu 14.04

喜夏-厌秋 提交于 2019-12-12 01:53:31

问题


Question:

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

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

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

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

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]

if i switch users:

 +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

I'm a super noob when it comes to permissions, so I hope you can hold my hand

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

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

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??

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

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

回答1:


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

If you want to install something for all users, use

apt-get install

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)

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"

as a privileged user (root or possibly ubuntu) run

apt-get install ruby-full

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?

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"

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)

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

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 >



来源:https://stackoverflow.com/questions/27670407/set-up-ruby-globally-for-all-users-on-ubuntu-14-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!