Toby Toby - 9 months ago 66
Ruby Question

How to run bundle install as normal user

I am attempting to use

bundle install
. I am not a Ruby user - this is my first real foray into even running rake. I'm simply trying to user some packages from that use Rake and so on.

I initially installed ruby several days ago using:

sudo apt-get install ruby-full

This allowed me to use rake with Unity testing framework. Now I'd like to use CMock. the instructions for using CMock say to
into the directory then

$ bundle install
$ bundle exec rake

So I install bundler using:

$ sudo apt-get install bundler

But then running the
bundle install
continuously asks me for my password. So I try:

$ gem install bundler

Which fails for write permissions on /var/lib/gems/1.9.1. So I try:

$ sudo gem install bundler

which installs OK so I try the
bundle install
again. But still get continuously asked for my password. So I try:

$ sudo bundle install

And get a warning that I should not run bundler as root:

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.

How can I install this properly so that I can run it as expected?

Note: I have seen that there are several other questions on this topic, none of which I understood the answers to so let me underline that I am not a ruby (or even web stack) dev - I need this in layman's terms as much as possible.

Note also: I did see several mentions of RVM and rbenv. I'm not sure if they were incidental to those questions in particular or if one or both is required. I do not currently have either. Am about to research exactly what they are now.

Note the third: My platform is WSL (so Ubuntu, kind of).

Answer Source

I've been working with Ruby only a few weeks now. I'll say, I know where you are. I am not about to help much but will say, to your last question in the comments, that my understanding is that the two commands are different.

My understanding of a short answer.. One can have diff versions of Ruby they need to work with (legacy projects, etc) and not every version of Ruby can run every version of a given gem. For this reason, one can use rbenv or rvm to help manage the art of setting up a project with a particular version of ruby and then installing the needed gems.

I've been working with rvm on my mac and rbenv in linux and find them both similar enough for the simple stuff I've been doing. Installing rbenv on linux proved slightly easier. Once set up properly, sudo is no longer needed to install gems - which is preferred. I would recommend trying one of these and installing per their website instructions. Things should go smoother once set up.