To start I follow the exact steps from Setup Ruby On Rails on
macOS 10.13 High Sierra, just like I have with every other version of mac/ubuntu.
So basically install homebrew, install rbenv ruby-build
add the following to bash profile and source it:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
then do
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v
outputs:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
do a which ruby to to make sure:
/Users/pdavies/.rbenv/shims/ruby
run gem install
gem install rails -v 5.2.0
which outputs:
Successfully installed rails-5.2.0
Parsing documentation for rails-5.2.0
Done installing documentation for rails after 0 seconds
1 gem installed
then a rehash and check version:
rbenv rehash
rails -v
outputs:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
found anther issue that suggested adding:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
to the bash profile, did that sourced it and tried again still nothing. to check the output of echo $PATH was:
/Users/pdavies/.rbenv/shims:/Users/pdavies/.rbenv/bin:/Users/pdavies/.rbenv/shims:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
Just to make sure i also did which gem incase i wasnt using the right one, output:
/Users/pdavies/.rbenv/shims/gem
when I do a which rails i get:
/usr/bin/rails
I found some blog that said to delete that, but I cant seem to do that either, i just get:
sudo rm -f /usr/bin/rails
Password:
rm: /usr/bin/rails: Operation not permitted
This is a fresh install of OSX and the only way I can get it work is to downgrade the version of OSX that is installed, which is a pain in the ass!
Any help would be grateful
Thanks
Related
I have recently moved from RVM to Rbenv and when attempting to execute rails I am getting an error like the one below
Pauls-Air:~ $ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.1.2
After installing a gem via the command line in a ruby version you have to execute rbenv rehash as described in the docs here and here
For example:
$ rbenv install 2.2.0
$ gem install bundler
$ rbenv rehash
$ gem install rails
$ rbenv rehash
You need to install Rails for each Ruby version within rbenv. Try running rbenv version, I might expect that 2.1.2 is not the ruby version in use for the current project (local version) or maybe your global version.
I ran into the same issue, but none of these other solutions (or any of the others I found elsewhere) worked. I was about to go back to RVM, so I decided to get rid of rbenv completely and it paved the way to the solution.
Try the following - it worked for me:
uninstalling rbenv, remove all references rbenv in your bash profile, and remove the remaining rbenv file folder and its contents.
Reinstall rbenv with homebrew.
Add it back to your bash profile:
export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
Restart the shell:
exec $SHELL -l
Check the path:
echo $PATH
Install Rails:
gem install rails
rbenv rehash
Note: I consulted this for part of this answer: https://www.codementor.io/tips/3732499178/solution-for-rbenv-rails-is-not-currently-installed-on-this-system-to-get-the-latest-version-simply-type
Try to set up your environment with 2.1.2 version running this command line in your terminal:
$ rbenv shell 2.1.2
It works to me
Ensure that the .ruby-version file in your project's directory contains the same ruby version as the one you installed with rbenv.
For me, I set up my environment with the listed "The `rails' command exists in these Ruby versions".
$ rbenv shell 2.1.2
$ rails -v
It works.
Like for example if you want to install Ruby 2.5.3 with Rails 6
follow this way:-rbenv global 2.5.3
$ gem update --system
$ rbenv install 2.5.3
$ rbenv global 2.5.3
$ gem install rails -v 6.0.2.2
$ ruby -v
$ rails -v
The problem is that your global ruby version doesn't match your installed somewhere locally version which is 2.1.2. Try executing anywhere in bash shell:
rbenv global 2.1.2
That way rails will be found by rbenv in your $HOME directory and anywhere else.
rbenv global
Sets the global version of Ruby to be used in all shells by writing
the version name to the ~/.rbenv/version file. This version can be
overridden by an application-specific .ruby-version file, or by
setting the RBENV_VERSION environment variable.
I'm trying to install Rails onto my Mac and keep running into a this issue. I have no coding/programming experience and am trying to get set up so I can start learning.
I have gone through everything on install rails.com and am not sure what to do.
Your help is appreciated.
make install failed, exit code 2
Gem files will remain installed in /Users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Follow the steps below to install ruby on rails on mac osx yosemite.
If that does not work please post the exact errors.
For further details about the installation have a look at https://gorails.com/setup/osx/10.10-yosemite
Installing Homebrew
You might be asked to install the XCode CommandLine Tools - say yes.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
you can browse the available versions using
rbenv install --list
installation using homebrew
brew install rbenv ruby-build
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
# Install Ruby
rbenv install 2.2.1
rbenv global 2.2.1
now ruby is installed and you should be able to run
ruby -v
# ruby 2.2.1...
Installing Rails
you can browse the available versions of rails using
gem list ^rails$ --remove --all
installation
gem install rails -v 4.2.1
to use the rails command run
rbenv rehash
now rails is installed and you should be able run
rails -v
# Rails 4.2.1
I am setting up my new machine (Mac Yosemite) and when I run the command "bundle" I get the following error:
Your Ruby version is 2.2.1, but your Gemfile specified 2.2.0
I'm trying to change the version w Rbenv but I think it's not working.
ruby -v
// Ruby 2.2.1p85
rbenv version
// 2.2.0
Can anyone help me? Thanks in advance!
Try to use rbenv local [version number].Refer to this for more understanding.
I had a similar problem but with ruby -v 2.2.0 and Mac OSX El Capitan. What finally worked for me was:
gem install bundler (apparently it was no longer installed)
rbenv rehash
bundle install
I was able to find the answer on the github for rbenv.
https://github.com/sstephenson/rbenv/issues/697
Assuming you have Ruby -v 2.2.0 installed (rbenv install 2.2.0 otherwise), change your ruby version with rbenv:
rbenv global 2.2.0
after install rails you must do this: rbenv rehash, in order to tell rbenv to see rails as executable.
follow this tutorial to set up Ruby and Ruby on Rails in your machine: https://gorails.com/setup/osx/10.10-yosemite
Note: In my case. after install rbenv the command rbenv global 2.2.0 doesn't affect my current ruby version (ruby -v still be the previous one). I fix this issue reinstalling rbenv and run this command:
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
immediately afterwards, as explained above in the tutorial.
I'm getting started with Rails development and have a dev environment setup on OS X Yosemite, but the Ruby and Rails versions are a bit wonky. I used homebrew to install Rails, and everything seems to have gone well. Although which rails claims it's located in "~/.rbenv/shims/rails", and not /usr/local/bin where homebrew is supposed to place its apps. There's also /usr/bin/rails which when run yields:
Rails is not currently installed on this system. To get the latest
version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
rails --version returns Rails 4.2.0.
I can create a rails app fine, but when I run rails server the ruby version is ruby 2.1.5 (2014-11-13) [x86_64-darwin14.0].
I followed these instructions (mac-dev-env.patrickbougie.com/ruby-22/) to compile ruby 2.2.0 and ruby --version returns "ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]". which ruby returns "/usr/local/rbenv/shims/ruby".
Relevant lines in .bash_profile from brew install of Rails and compiled ruby 2.2.0 are:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH=/usr/local/openssl/bin:$PATH export
MANPATH=/usr/local/openssl/ssl/man:$MANPATH export
PATH=/usr/local/rbenv/bin:$PATH export RBENV_ROOT=/usr/local/rbenv
eval "$(rbenv init -)"
How do I get the 2.2.0 version of Ruby to run with Rails? Everything I have read thus far suggests rvm (rvm.io). However, I get homebrew errors when I try to install Ruby that way.
From: http://railsapps.github.io/installrubyonrails-mac.html, section: "If You Already Have RVM Installed"
$ rvm get stable --autolibs=enable
$ rvm install ruby
$ rvm --default use ruby-2.2.0
rvm install ruby throws the homebrew error.
rvm seems unnecessary considering Ruby 2.2.0 is compiled on my machine already.
I appreciate any help, thank you!
I'm trying to get ruby 2.1.4 installed via rbenv for a client project.
Though previously I've been able to install ruby versions through rbenv, after upgrading to Yosemite, I keep getting the following error:
rbenv: no such command 'install'
After digging around, I saw lots of tips about how "install" comes from the ruby-build plugin, which is installed via homebrew:
which ruby-build
/usr/local/bin/ruby-build
I installed rbenv via Homebrew, but when I try use which rbenv, I get:
rbenv () {
typeset command
command="$1"
if [ "$#" -gt 0 ]
then
shift
fi
case "$command" in
(rehash|shell) eval `rbenv "sh-$command" "$#"` ;;
(*) command rbenv "$command" "$#" ;;
esac
}
I have run brew update and brew upgrade rbenv ruby-builder, and it tells me everything is up to date.
Below is my full $PATH:
zsh: no such file or directory: /usr/local/var/rbenv/shims:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/local/sbin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/bin
UPDATE: Found another answer with a little deeper digging on github that showed signs of promise, but failed to solve the issue with rbenv. https://github.com/sstephenson/rbenv/issues/610#issuecomment-56240018
I believe 2.1.4 is now installed on my machine, but it installed here:
Successfully installed ruby 2.1.4 into /Users/dannycox/.rubies/ruby-2.1.4
As a result, my bundler won't work with the new ruby 2.0 version and I get the following error when I try to gem install bundle:
Fetching: bundler-1.7.6.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
Still need help to identify why ruby-build isn't playing nice with rbenv...
Make sure to install optional step 5 in the instructions:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Install ruby-build, which provides the rbenv install command that simplifies the process of installing new Ruby versions.
I had similar problem, and trace the problem to ruby-build. So i updated the homebrew and reinstall the ruby-build
> brew update
> brew reinstall ruby-build
Find the ruby version
> brew ls -v ruby-build | grep 2.1.4
then install intended version ruby again
> rbenv install 2.1.4
From your perms error I think you are trying to install to the system ruby, which is the one that comes with Apple OSX. You want to use rbenv to install your own ruby and install gems into that.
Read - https://github.com/rbenv/ruby-build#readme
And use the
rbenv versions
command to show what instance of ruby you are about to install the gems into. If it's system then you need to install your own ruby instance and then use that ruby for gems.