lots of instructions online show that we need to install Ruby on Rails on linux. Can we actually install it on Mac? Because Ubuntu is too slow on Mac so far, I wanna change to Mac itself instead of using a virtual machine.
Sure, we can use MacOS for development, and Linux for production.
Yep. It's simple. Open Terminal and follow this steps:
Install Homebrew:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Upgrade ruby version:
$ brew install rbenv ruby-build
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile
$ rbenv install 2.5.0
$ rbenv global 2.5.0
Install last rails version:
$ gem install rails -v 5.1.4
$ rbenv rehash
Related
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
I am learning to code and trying to make the move for a Rails project from a cloud dev environment to a local one on my Mac with OS Sierra. However, I am having trouble setting up my ruby version and installing rails.
I have installed Homebrew which I used to install rbenv. Using rbenv I have installed ruby 2.4.0 and set it to local and global. I can see it in .rbenv/versions, however when I check my ruby version I still get 2.0.0
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
When I try and install Rails I get the following;
$ gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I am not sure how I utilize the rbenv ruby version in my system to then install rails.
You probably need to add rbenv to your ~/.bash_profile:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
Then source it:
source ~/.bash_profile
Then you can use the rbenv command:
# install a Ruby version:
$ rbenv install <version>
# show versions currently installed and indicate current version
$ rbenv versions
# set ruby version for a specific dir
$ rbenv local <version>
# set ruby version globally
$ rbenv global <version>
# list all available versions:
$ rbenv install -l
The rbenv command is used to install, switch between versions, etc.
I'm on MacOS Sierra
brew doctor says no problem
xcode/gcc is installed
My first problem is no response when I use curl.
And here is what I get when I trace the installation.
After the installation is complete, I restart my terminal and try and use 'source ~/.rvm/scripts/rvm', but I get an error 'No such file or directory'
I've tried to delete the directory and re-install a couple of times, but no luck.
EDIT: If I don't use -sSL, I get two lines of output, but still no luck: imgur.com/a/bxyLy
EDIT2: https://github.com/rvm/rvm/issues/3910 allows installation
Use rbenv instead of rvm, rbenv is most suitable than rvm.
Homebrew setup:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
rbenv setup:
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.4.0
rbenv global 2.4.0
ruby -v
I cannot install ruby new version. I stall the home-brew and ruby-build, both install successful. I type $ rbenv, it shows
...
install Install a Ruby version using ruby-build
...
then i stall version 2.3.1
$ rbenv install 2.3.1
it shows error
Zhimings-MacBook-Pro:~ zhimingjiang$ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
mkdir: /usr/local/var/rbenv/versions/2.3.1/lib: Permission denied
BUILD FAILED (OS X 10.11.5 using ruby-build 20160426)
Inspect or clean up the working tree at /var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035
Results logged to /var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035.log
Last 10 log lines:
/var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035 ~
/var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035/ruby-2.3.1 /var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035 ~
I does't have path /usr/local/var/rbenv, I only have path /usr/local/rbenv
Additions (here is the tutorial i have watched
https://www.youtube.com/watch?v=jx0NrIbQbzI)
You can try install ruby via rbenv following as this tutorial:
I tried it and success.
install rbenv on osx
Update:
You should do these steps as below:
brew install rbenv
brew install ruby-build
echo 'export RBENV_ROOT=/usr/local/var/rbenv' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
Then you used rbenv to install ruby. First, find the desired version:
rbenv install -l
And rbenv install 2.3.1
I find out
https://www.ruby-lang.org/en/documentation/installation/
search key words "Building from Source"
follow the instruction
download -> unzip -> terminal cd into folder -> star to type those 3 line commend.
also if install other which require ruby. You may still need to type $./configure --with-openssl-dir=/usr/local/ssl
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