JM:repositories jm$ rails new islandinkjet - postgresql
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.
JM:repositories jm$ sudo gem install rails
Password:
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
JM:repositories jm$ JM:repositories jm$ rails new islandinkjet - postgresql
-bash: JM:repositories: command not found
JM:repositories jm$ Rails is not currently installed on this system. To get the latest version, simply type:
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.
Sorry, I'm not sure what's happening on your system, so I can't really tell you how to solve this.
It's not a ruby-build problem, since you seem to already have a working Ruby version. However, if you installed Ruby with ruby-build, then I'm guessing you might manage your Ruby versions with rbenv. In that case, you should never use sudo to install gems, since that will install them in the wrong location. Instead, just do gem i rails. After that, do which -a rails to verify which executable you are running.
Thanks for your reply mislav.
When I try your solution I got this:
JM:repositories jm$ gem i rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Oh, that means you are using system Ruby (the default Ruby preinstalled on macOS), and that you're not using a version through rbenv. You haven't told us how you set up your system at all, so I don't know what to tell you. But if you installed a Ruby version through ruby-build (this project) or rbenv, please first make sure it's selected (rbenv global <my-version>), and then try installing the gem again.
Thanks again mislav. It seems to be working fine now.
This is what I did:
vi ~/.bash_profile I set my path as ..export PATH=/usr/local/var/rbenv/shims:/usr/local/bin:$PATH
export RBENV_ROOT=/usr/local/var/rbenv
Had similar situation. which -a rails was helpful in determining that /usr/bin/rails was being picked up on PATH rather than the shim. Put the following into ~/.zshrc:
# Needed for rbenv
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
Thanks for your solution @arcseldon, it fixes my issue! However everytime I need to type the following in my terminal everytime I open a new window:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
Do you know how I can fix this problem permanently?
@lucasdidier Did you put those lines in your shell profile as arcseldon recommended? If so, they should be automatically loaded whenever you open a terminal.
Most helpful comment
Had similar situation.
which -a railswas helpful in determining that/usr/bin/railswas being picked up on PATH rather than the shim. Put the following into~/.zshrc: