I'm trying to install Ruby + Rails on Ubuntu 14.04. I need more than one user to have access to Ruby, so I installed rbenv with ruby-build in the /opt/.rbenv directory. Is that right?
If I try to install a version of Ruby using
rbenv install 2.1.3
it is installed in ~/username/.rbenv/versions, not in /opt/.rbenv/versions.
I don't want to give the second user access to the other user's home directory.
How can I install Ruby in /opt/.rbenv? Or is there another solution?
You can use the RBENV_ROOT environment variable:
sudo RBENV_ROOT=/opt/.rbenv rbenv install 2.1.3
See documentation.
Related
I had the original ruby v2.6.8 I believe on my mac os. I wanted to upgrade to ruby 3.1.2 to get access to rails.
I installed ruby via homebrew, however I decided it woud be easier to manage using rbenv. I went to uninstall ruby via homebrew, and then instaled ruby 3.1.2 with rbenv.
Now when I use the
ruby -v
-bash: /usr/local/opt/ruby/bin/ruby: No such file or directory
using the command which ruby brings me this:
/Users/user/.rbenv/shims/ruby
So the ruby is there, and rbenv claims it installed ruby 3.1.2, but did homebrew install all of ruby including the version osx came with? Im pretty sure thats a yikes moment if it did. I also can't use any ruby commands under these circumstances so I don't really know what to do from here?
How do I get my $PATH to recognize the rbenv path to ruby as the global path? I'm on MacOs 11.3.1 BigSur if thats relevant.
Follow the next steps to set up rbenv, and ruby 3.1.2.
Step 1
brew install rbenv
Step 2 Add the following lines to your .zshrc file
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
Step 3
brew update && brew upgrade ruby-build
Step 4
rbenv install 3.1.2
rbenv global 3.1.2
I've read similar questions but still unlucky. In my server (Ubuntu 16.04) I have two user: root and other. I want to config a Rails project.
Now, after some configuration I installed the v2.5 version of Ruby (required) as a root user using Rbenv, but in the other profile the version kept the same as default (v2.3).
I've managed to know set the proper version in the other profile. When I do:
rbenv versions
The output is the following:
system
* 2.5.0 (set by /home/other/.rbenv/version)
But when I do:
ruby -v
The version keeps being the default one:
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
How to set the version to v2.5?
Thanks in advance.
when you run ruby -v, it's considering your ruby installed by apt install ruby.
You must remove ruby-build with apt remove ruby-build and clone the ruby-build to inside rbenv directory and then install and set as global with rbenv.
I want to recommend you to read and follow this tutorial after remove local ruby-build.
I already have installed ruby 2.3.1p112 and rails 5.0.0 but I need install another version of ruby and rails, so I will install rbenv. What the right path to follow ? Do I need remove ruby and rails before install rbenv ?
as part of the installation you will add stuff to your bash profile which will clobber the system ruby / gem environment. You shouldn't have to do anything, just proceed with the rbenv install documentation.
Am trying to set up rails on mac using rbenv and Homebrew.
Currently getting the following message when attempting to 'gem install rails':
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
username-mbp:projects username$ gem install rails
Any ideas??
If you are using rbenv, you should not use sudo to install gems. rbenv very helpfully installs your gems under your home directory in a way that allows you to use different gems for each installed Ruby version. When you change versions of Ruby you will really appreciate this.
To see the current version of Ruby, use rbenv local. For me this prints:
2.2.2
To see all the Ruby versions on your system of which rbenv is aware:
rbenv versions
rbenv stores the version specifier in a file called .ruby-version. This allows you to use different versions of Ruby for different projects, each version having its own set of gems.
When you try to install rails and get the Gem::FilePermissionError, it means that rbenv is not active, or you are deliberately installing into the "system" Ruby. There is nothing wrong with this per se, but you are not taking advantage of rbenv.
I recommend installing Rails again, using rbenv local to ensure that you are adding the gems to the correct path. You'll know this is working when
gem env gemdir
produces something like:
/Users/username/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
See https://github.com/sstephenson/rbenv#installation for more info.
This probably means that you used sudoat some point, which means that you run a command that allows you (as a permitted user to execute a command as the superuser or another user) See here: http://linux.about.com/od/commands/l/blcmdl8_sudo.htm.
Can you please paste the commands you used for installing rbenv, ruby, gem, brew, etc.? Also please paste the output of brew doctorto see if environment is correctly configured for Homebrew. Also, please paste the OSX version and rbenv versionsif rbenv is installed.
The steps for installing ruby on rails on OSX are:
Install Homebrew by:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` (as seen here: http://brew.sh/). Run brew doctor and brew updateto see if everything is fine.
Install ruby: OS X comes with Ruby installed (Mavericks/Yosemite even gets version 2.0.0, previously it was only 1.8.7).
Install rbenv: it can be done either by GitHub Checkout or Brew. You probably should use brew. Run brew install rbenv ruby-build(this will also install ruby-build -https://github.com/sstephenson/ruby-build#readme-). You can also use this command brew install rbenv ruby-build rbenv-gem-rehash. Then echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (to enable shims and autocompletion). You should problably run this too: echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile. Close terminal and open it again. Install the preferred version of ruby (if you want): rbenv install 2.0.0-p353.
Install Bundler: gem install bundler.
Install SQLite: gem install sqlite3
Install Rails: gem install rails.
So, the error you are having is due to permissions (you can understand about them here: http://www.tutorialspoint.com/unix/unix-file-permission.htm). Many people suggest fixing the issue with sudo or chown (http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/). I don't recommend that as it messes with system configuration. It will be better that you run:
rbenv install 2.1.2
rbenv global 2.1.2
gem update --system
When I run with this error like a year ago, what I did was uninstall everything and start again... but, probably that'll take too long.
These links might help you:
ruby for mac, ruby rbenv, rbenv githube, rubies and gems, question on stack
Use sudo:
sudo gem install rails
This guide helped me a lot: Setup Ruby On Rails on
Mac OS X 10.10 Yosemite
Accidently I have installed both versions of ruby on my system and now the default version is set to
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
but I need to set the default version to 2.0.0...
for this I used the command
$ rvm 2.0.0p294 --default
but it says rvm is not currently installed though I installed it, typing various commands(via google) .
Also I want to install an Integrated Ruby shell in ubuntu 13.04, do suggest how to do it.
I have also installed Aptana Studio on my system, now how should I get started with it.
Finally, the last problem is tell me how to check whether rails is currently installed in my system or not...
Thanx in advance!!
to use a gemset try writing
rvm use ruby_gemset_version
to check the rails version try to type rails -v
you have to install RVM (ruby version manager), then you have control to use any specific versions of ruby, and coming to rails you have to manually install rails gem once you have installed rvm and selected a version.
This would be helpful to install rvm
https://rvm.io/rvm/install
After installation you have to install ruby versions.
Then you can use the following cmd
$ rvm use 2.0.0
to use ruby 2.0.0
Thank you.
Go to this http://rvm.io/rvm/install It has instruction to install and cofigure RVM. It is dependant on CURL lib. So make sure you have curl installed in your system, if not then the command is
#sudo apt-get install curl
Once it is intalled and configured properly.
On Ubuntu:
GoTo Terminal > Profile Preferences > Title and Command > Set checkbox for (Run command as login shell)
Install rubies using rvm install.