RVM finding system gems' executables - ruby-on-rails

I have installed RVM along with ruby versions. However if I fire up the console and run the command rails server, bundle install, etc. I get this error
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory
But if I run rvm use 1.9.2 first, then everything is ok. I tried using `rvm use --default 1.9.2' but nothing changed. Does this mean it uses a different ruby from the ones in RVM? Thanks in advance!

Explanation of rubygems bin folders and PATH
Oh. You didn't have rails installed in your rvm ruby, but you did in your system ruby.
Individual gems, like rails can have a bin directory that will contain executable helper scripts. Your system default rubygems is making symlinks from your system /usr/bin/ dir into the gem's bin folder for these helper executables.
RVM provides a similar facility, except instead of polluting the system /usr/bin dir, it just appends its ~/.rvm/gems/#{rvm_gemset_string}/bin folder to the PATH environment variable.
Importing system Rubygems list into your new rvm rubies' gem directories
RVM by default will not import your gems from your system ruby installation into your rvm ruby installs. It makes a full clean fork of the entire ruby system including rubygems (the gem 'rubygems') and rubygems' gem list. When you rvm install 1.9.2 it's like you've made a completely new install of everything used with ruby.
If you'd like to get all your system ruby gems that you were previously using into your preferred rvm ruby, try this:
rvm use system
rvm gemset export system.gems
rvm use 1.9.2
rvm gemset import system.gems
#You'll now have all your system gems reinstalled to your new ruby version
Original Answer/ Edits from #Telemachus
Try moving the lines that source rvm to the end of your ~/.bash_profile or ~/.bashrc (whichever you have it in):
'[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function'
.
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file ...
| | ^--------------------------------\
^ Bash, not rvm; ^/usr/bin/rails, not ~/.rvm/gems/*/bin/rails; |
Some ruby leftover from a previous install in the os
You have rails installed in /usr/bin, which is probably before the rvm ruby bin path in your bash echo $PATH variable, so it's finding the system rails install (/usr/bin/rails, a ruby script) which starts like this:
#! /usr/bin/ruby18
You've gotta make the conflict stop happening, the best of all possible ways is making sure that RVM's bin dir is at the beginning of your PATH. This happens in the #Load rvm environment script that you added to your ~/.bash_profile when installing rvm. If you installed rvm as a system library rather than just for your user, this will be different.
If you get to that case, ask #Telemachus.
You'll then need to ensure you've gotten the rails gem installed in your new rvm ruby as above.
Acceptance Test:
You'll find that when you've done rvm use 1.9.2, then which ruby will return something like ~/.rvm/rubies/1.9.2/bin/ruby, and which rails should return something like ~/.rvm/gems/*/bin/rails.

I just solved the same problem on Windows Vista.
My console was giving me this message:
$ rails -v
sh: /c/RailsInstaller/Ruby1.9.2/bin/rails: C:/Projects/railsinstaller/Stage/Ruby1.9.2 /bin/ruby.exe: bad interpreter: No such file or directory
I just edited the first line of this file:
C:\RailsInstaller\Ruby1.9.2\bin\rails
And made it point to the correct location for ruby.exe, on my system, like this:
#!C:\RailsInstaller\Ruby1.9.2\bin\ruby.exe
Et voilà, problem solved!

You need to run rvm use --default 1.9.2, not just rvm use --default.

Related

Ruby on Rails error, Ruby was not installed but it is installed

I have followed this thread and followed Linuxios' answer, everything was working fine but then I get
-bash: export: `[[': not a valid identifier
-bash: export: `-s': not a valid identifier
-bash: export: `/Users/duaneadam/.rvm/scripts/rvm': not a valid identifier
-bash: export: `]]': not a valid identifier
So, I went and removed from .bash__profile via Terminal.
export PATH=$PATH:/usr/local/git/bin/ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
.. thinking that lines of code is the problem but what I get after that is even worse. For some reasons.. Ruby is not installed.. again.
So, I re-added the lines of code and tried rebooting/restarting my Mac but problem still persist.
Screenshots:
.bash_profile:
Solution please? I even tried re-installing using his method.
Gosh, this is hard maybe Ruby on Rails isn't just for me.
Setting up ruby with rvm can get pretty complicated at times.
A few golden rules is never to sudo when using a package manager like rvm.
Try the following:
rvm implode (This essentially removes the rvm installation
completely.)
Remove all references of rvm from ~/.bash_profile and ~/.bashrc
which ruby (The output should be something like /usr/bin, also ruby --version should be 1.8.7, the default bundled with OS X.)
Install rvm again in a single user mode.
Install the ruby version of your choice.
Make sure to create the .rvmrc file where ever the ruby program resides. (Typical contents of .rvmrc -> rvm use ruby-version#gemset-name --create; eg: rvm use 1.9.3#my-awesome-project --create)
cd into the directory with .rvmrc
Make sure the right gemset is loaded with rvm gemset list
Also ensure that rvm is loaded as a function. (You can verify this by typing type rvm | head -1 in the console.)
Some more points, which were helpful to me from http://jfire.io/blog/2012/03/02/xcode-4-dot-3-homebrew-and-ruby/:
Install apple-gcc42, autoconf and automake (Using a package manager like homebrew can be useful.)
Also rvm requirements tells you what are the other tools you need to install.
Cheers!

Can't seem to "use" the RVM Ruby install

I'm getting this error when I try to invoke rails, rails -v or rails -c:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
I installed RVM, used it to install Ruby 1.9.3, and switched to it rvm use 1.9.3 --default.
When I ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
I also gem install rails --no-rdoc --no-ri and checked...ls ~/ruby/gems/gems/:
actionmailer-3.2.8/ journey-1.0.4/ rake-0.9.2.2/
actionpack-3.2.8/ json-1.7.5/ rdoc-3.12/
activemodel-3.2.8/ mail-2.4.4/ rubygems-bundler-1.0.7/
activerecord-3.2.8/ mime-types-1.19/ rvm-1.11.3.5/
activeresource-3.2.8/ multi_json-1.3.6/ sprockets-2.1.3/
activesupport-3.2.8/ polyglot-0.3.3/ sprockets-2.4.5/
arel-3.0.2/ rack-1.4.1/ thor-0.16.0/
builder-3.0.0/ rack-cache-1.2/ tilt-1.3.3/
bundler-1.1.5/ rack-ssl-1.3.2/ treetop-1.4.10/
erubis-2.7.0/ rack-test-0.6.1/ tzinfo-0.3.33/
hike-1.2.1/ rails-3.2.8/
i18n-0.6.0/ railties-3.2.8/
And if I echo $GEM_PATH:
/home/flackend/.rvm/gems/ruby-1.9.3-p194:/home/flackend/.rvm/gems/ruby-1.9.3-p194#global
echo $PATH:
/home/flackend/.rvm/gems/ruby-1.9.3-p194/bin:/home/flackend/.rvm/gems/ruby-1.9.3-p194#global/bin:/home/flackend/.rvm/rubies/ruby-1.9.3-p194/bin:/home/flackend/.rvm/bin:/usr/local/jdk/bin:/home/flackend/perl5/bin:/usr/kerberos/bin:/usr/lib/courier-imap/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/home/flackend/.rvm/bin:/home/flackend/bin
cat ~/.bashrc:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
cat ~/.bash_profile:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
So somewhere something has a path that says to look at the system Ruby install. Any ideas? Thanks!
EDIT
Okay, also, If i switch back to the system Ruby, rvm use system, and rails -v, I get:
Rails 2.3.8
So I have no idea at all what this error is indicating.
You have not completed rvm installation. You need add ~/.rvm bin paths before /usr/bin by command in .bashrc:
[[ -s "/Users/pftg/.rvm/scripts/rvm" ]] && source "/Users/pftg/.rvm/scripts/rvm".
To test just check $PATH env. Should be similar to:
/.../.rvm/gems/ruby-1.9.3-p125#global/bin:/.../.rvm/rubies/ruby-1.9.3-p125/bin:/.../.rvm/bin:/usr/local/bin
If you installed everything ruby as well as rails means, you may need to select the 'Run command as login shell' checkbox by doing following,
Open terminal
Go to Edit tab, then select Profile Preferences from the menu item.
The Profile Preferences window should be displayed, then select Title and Command tab.
Then select the checkbox Run command as a login shell.
I just used RVM to create a "gemset", switched to it, and tried installing Rails again and it works now.
https://rvm.io/gemsets/
I'm not sure why that fixed it or why it wasn't working before. I like when things work, but I would rather have figured out why it wasn't working with the #global gemset.
Thanks for all your help!
I had the exact symptoms described above as well and was stuck on this problem for quite some time (the ruby environment and dependencies are a horrible mess). I can't say I'm out of the woods yet but at least I'm picking up the correct version of rails now and gotten past this error.
I believe the real issue here is actually to do with zlib. It seems that it's a crucial component to separate your system version of ruby (v1.8 likely install via yum/apt-get) with the other versions or Ruby you need (installed via rvm) for other projects.
If you do not have zlib installed, or rvm is not using it correctly, then sometimes you will pick up the system ruby/rails and all sorts of strange errors occur.
If you DO have zlib installed (yum/apt-get install zlib) then the trick I discovered was that I specifically had to tell rvm which version of zlib to use when installing ruby.
rvm install 1.9.3 --with-zlib-dir=$rvm_path/usr

Use my system's gems instead of an RVM gemset on a pre-bundler Rails app

I have several old (pre-bundler / pre-rvm) Rails projects that use my system's gems.
Now I've installed RVM to ride the latest Rails version, but my old applications are now using a gemset: (I'm not sure exactly what I did to make this happen)
~/rails_apps/rapgenius >: echo $GEM_HOME
/Users/tom/.rvm/gems/ruby-1.8.7-p302
I want to use my system's gems by default, and, if I have an .rvmrc file in a directory, I want to use the gemset it specifies in that directory. Like this:
~/rails_apps/reader2000 >: cat .rvmrc
rvm 1.9.2#reader2000
~/rails_apps/reader2000 >: echo $GEM_HOME
/Users/tom/.rvm/gems/ruby-1.9.2-p0
How can I achieve this?
You can try
rvm use system --default

Error when executing rvm rubygems latest

I'm adding ruby 1.9.2 to a Mac running 10.6.8 and hitting a problem with rvm rubygems latest. I've run the following with no problem:
$ rvm install 1.9.2
$ rvm use 1.9.2
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
Then hit this error:
$ rvm rubygems latest
Removing old Rubygems files...
Installing rubygems-1.8.10 for system ...
ERROR: Error running 'GEM_PATH=":#global" GEM_HOME="" "/usr/local/rvm/rubies//bin/ruby" "/usr/local/rvm/src/rubygems-1.8.10/setup.rb"', please read /usr/local/rvm/log/system/rubygems.install.log
WARN: Installation of rubygems did not complete successfully.
ln: /usr/local/rvm/rubies//lib/ruby/gems/: No such file or directory
The obvious thing here is the extra forward-slash in the bin/ruby and lib/ruby paths. Any ideas where this is coming from and how to fix it?
Note that I've also got the following line at the end of my .bash_profile file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
I'm doing all of this so that I can run Octopress. I've also got a Rails 2.3.8 project that I am developing on this same machine. This is the first time I've dealt with anything other then the system version of ruby (1.8.7).
I've had the same problem, and although I didn't really fully understood why it was happening, attacking the main symptom solved it for me.
It seems that you have already another version of ruby installed on your system. The line on the rvm rubygems script that generates the error is this:
__rvm_run "rubygems.install" \
"GEM_PATH=\"$GEM_PATH:${GEM_PATH%%#*}#global\" GEM_HOME=\"$GEM_HOME\" \"${rvm_ruby_binary}\" \"${rvm_src_path}/$rvm_gem_package_name/setup.rb\"" \
"Installing $rvm_gem_package_name for ${rvm_ruby_string} ..."
https://github.com/wayneeseguin/rvm/blob/master/scripts/rubygems#L104
I think that internally rvm is losing itself and creating paths with the double slash on it, probably because RVM is appending the RVM local dir with the output of some command similar to which ruby (or whatever the path rvm is searching for may be). I really don't know why it does that (doesn't RVM work in a system with ruby installed?).
Anyhow, to fix that in my machine I simply ran sudo aptitude purge ruby (you would of course run the MAC equivalent of that), to remove the ruby version that was messing with rvm.
If you have something related with ruby installed on your computer, I think a good idea would be to remove them all, and use RVM to manage all your ruby related goodness.
On linux (debian/ubuntu), a good approach is typing dpkg -l | grep ruby to see which packages related to ruby are installed on your machine, and then purge them all.
After that, run
$ rvm use 1.9.2
$ rvm rubygems latest
Everything should work like a charm. At least uninstalling ruby worked for me.
Hope it helps.
I just ran rvm default which allowed everything to work properly. I fields is right that rvm hasn't set something completely or at all. This has actually fixed this problem for me consistently.

Rails keeps telling me that it's not currently installed

I use rvm to manage different rubies and their gemsets. My shell is zsh with oh-my-zsh configured with basic settings. Enabled oh-my-zsh plugins are ruby, rails, osx, and git. Here's the command I used to install ruby-1.8.7 and rails-3.0.7.
rvm install 1.8.7
rvm use 1.8.7
gem install rails -v=3.0.7
and then I typed rails and got:
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.
I've tried more thorough installs also, Like reinstall rubygems after switching to ruby-1.8.7, or create a completely new gemset, but with no luck.
Here's the rvm info:
ruby-1.8.7-p352#rails:
system:
uname: "Darwin yicai.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
version: "rvm 1.8.6 by Wayne E. Seguin (wayneeseguin#gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2011-06-30"
platform: "i686-darwin10.8.0"
patchlevel: "2011-06-30 patchlevel 352"
full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]"
homes:
gem: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails"
ruby: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
binaries:
ruby: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
irb: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
gem: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
rake: "/Users/nil/.rvm/bin/rake"
environment:
PATH: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails/bin:/Users/nil/.rvm/gems/ruby-1.8.7-p352#global/bin:/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin:/Users/nil/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/sbin"
GEM_HOME: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails"
GEM_PATH: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails:/Users/nil/.rvm/gems/ruby-1.8.7-p352#global"
MY_RUBY_HOME: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
IRBRC: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
RUBYOPT: ""
gemset: "rails"
and the gem version is 1.8.10, the latest.
If you're running a rails command immediately after installing rails, you will need to restart your terminal before your commands will be recognized.
I had this problem today. Not completely related to your question, but since this page is what comes up in Google when I search for "Rails is not currently installed on this system", I thought I would add my answer:
What happened is that I was using ruby 1.9.2 with rails for a while, but then I needed to use ruby 1.8.7 to run some other script that I found.
Afterwards, I wanted to change by system back to using 1.9.2, and that's where the problem started:
$ rvm list
=> ruby-1.8.7-p352 [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
$ rvm use 1.9.2
I thought that would do the trick. But no, that gives me the "Rails is not currently installed on this system" message.
What I had forgotten is that I had configured rails using an rvm gemset. So I needed to specify the correct gemset when I was selecting which ruby version to make active.
$ rvm gemset list_all
gemsets for ruby-1.8.7-p352 (found in /Users/asgeo1/.rvm/gems/ruby-1.8.7-p352)
global
gemsets for ruby-1.9.2-p290 (found in /Users/asgeo1/.rvm/gems/ruby-1.9.2-p290)
global
rails31
$ rvm use ruby-1.9.2-p290#rails31
That did the trick.
Mac OS X, rbenv, and rails
I was getting the exact same issue but with rbenv rather than rvm. After verifying a correct .bash_profile.
.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
Finally
I repeatedly installed and uninstalled rails but it was never placed in the .rbenv/bin directory after rbenv rehash. In the end I did a find . -name rails and uninstalled every gem that was returned and uninstalled rails. Then:
$ gem install rails
$ rbenv rehash
$ which rails
/Users/palmerc/.rbenv/shims/rails
I had the same issue and found that RVM was not showing as installed either if I tried the rvm command. All it took to fix both problems was running this command in the terminal
$ source ~/.rvm/scripts/rvm
Restart your terminal and then re-run your rails command
Rails is not reporting that it isn't installed. Your Debian system is telling you that rails isn't installed. One thing about rvm is that it relies on some complicated bash shell scripting and you sometimes need to start a fresh shell for changes to appear. You should also make sure that the correct rvm shell commands were added to your .zshrc file.
Also check your path to make sure the ~/.rvm/gems/... path in included.
I ran into this issue using rbenv. Turns out gem install rails did in fact install Rails but rails was not recognized as an executable. The fix for me was to run rbenv rehash.
I found this fix and more details on setting up Rails 5 at https://gorails.com/setup/osx/10.11-el-capitan
I have encountered this problem, but it has been resolved.
I use macOS, I do not use rvm, I only use HomeBrew, I first use gem env to get the installation directory of all gems, mine is:
$ gem env
RubyGems Environment:
   -RUBYGEMS VERSION: 3.1.2
   -RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin19]
   -INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
   -USER INSTALLATION DIRECTORY: /Users/myname/.gem/ruby/2.7.0
...
Then you try to go to /usr/local/lib/ruby/gems/2.7.0 to find the executable file directory of the rails gem that you have installed, for example: /usr/local/lib/ruby/gems/2.7.0/bin, then add to the path environment variable
I found this problem but the solutions above didn't solve it. I am not using rvm (and I'm working on mac) and I had to update the path to add rails executable directory:
echo 'export PATH="/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"' >> ~/.zshrc
I had a similar issue, but with rbenv.
I originally installed ruby on bash. Then I played around with .bashrc in VIM, messed that file up, and reset it back to default. In doing so, I unknowingly removed the exported rbenv $PATH. Because of this, my terminal no longer recognized that I had ruby installed.
I revisited the ruby installation page (https://gorails.com/setup/ubuntu/15.04) and tried to set up my rbenv path again with this command:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
It failed.
Luckily, I had already switched to zsh (with oh-my-zsh) between the time I messed up my .bashrc and the time I tried to access irb from my terminal.
My solution was to set up the rbenv path per the installation guide, but by replacing all instances of .bashrc with .zshrc like so:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
Hope this helps!
Here's what I've done. And the problem is gone. Hence I guess problem solved.
rvm use system
change to the system ruby. remove all gems in it using the command provided and explained here. then I install wanted ruby versions from scratch:
rvm install 1.8.7
rvm install rails -v 3.0.7
then bundle install
for further detail, might need dig into the gem install procedure.
add source ~/.rvm/scripts/rvm to your .bashrc file if rails installs fine but then you get the error "rails is not currently installed". This frustrated me for a while but I found the answer here: http://www.codelearn.org/blog/how-to-install-ruby-rails-screencasts-linux-mac-windows
I just reloaded my terminal
source ~/.bashrc
See: How do I reload .bashrc without logging out and back in?
Rbenv users
I had the same issue and this worked for me.
Setting the ruby version in the current directory.
rbenv local 2.7.1
Then I was able to run rails new
I had the same problem but the solution above didn't help.
This was my scenario
rvm list
=> ree-1.8.7-2012.02 [ i686 ]
ruby-1.9.3-p125 [ x86_64 ]
which ruby
/Users/dev/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby
which rails
/usr/bin/rails
gem list --local
..
rails (3.2.8)
rails2_asset_pipeline (0.1.20)
railties (3.2.8)
..
rvm use ruby-1.9.3-p125
which ruby
/Users/dev/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
which rails
/Users/dev/.rvm/gems/ruby-1.9.3-p125/bin/rails
By uninstalling rails and railties and reinstalling rails when using ree my problem was resolved.
Hope this helps others in my situation, not sure how I got into it :S
I had the same problem, I ended up deleting my .rvmrc rvm --create --rvmrc 1.8.7#project where the 1.8.7#project is whatever you want your ruby to be. cded in and out and it worked. http://sirupsen.com/get-started-right-with-rvm/
Just had same problem and couldn't find an answer. Here's what I did:
find current rails path
$ which rails
returns something like this: /usr/local/rails
Delete current version:
$ sudo rm -rf /usr/local/rails
Reinstall rails
$ sudo gem install rails
I ran into this same issue and none of the answers given helped so I thought I'd share my solution in case it might be useful for someone else.
I was messing around with my .profile and .bashrc files and along the way I messed up my RVM install. Still not sure exactly what I did, but the fix was easy. Just had to run the following command, which cleans up all of your system path settings for RVM:
rvm get [head|stable] --auto-dotfiles
Note that if you're running an old version of RVM this may upgrade your setup, which may not be what you want.
A possible solution is to not maintain two different configuration files .bash_profile and .bashrc
The solution as suggested in this excellent post on the difference between .bash_profile and .bashrc is to source .bashrc from your .bash_profile file, then putting PATH and common settings in .bashrc.
Quoting,
add the following lines to .bash_profile:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
end quote
I had this error after updating ruby. I had to run 'bundle install' to fix it.
Try to specify gemset explicitely in your Gemfile:
source 'https://rubygems.org'
ruby "2.2.3"
#ruby-gemset=rails424
Try This:
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use /bin/bash --login as the command.
$ bin/bash --login
$ rails -v
I had this message on my Mac:
Rails is not currently installed on this system. To get the latest
version, simply type:
and it was about the $PATH not being correct. The system has an outdated version of rails (/usr/bin/ruby). The path to your chosen version of ruby ($HOME/.rbenv/versions/2.3.0/bin) must precede the system's outdated version along $PATH var, like below:
export PATH="$HOME/.rbenv/versions/2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
adjust it to your version of ruby.
For MacOS (High Sierra):
Tokaido is the Rails installer system recommended on the "Getting Started" Rails guide page for Mac OS. But it doesn't just install, it runs its own shell scripts. If you start out using that, which sources its own shell environment, then later start a terminal without launching from the Tokaido shell, this happens, because the "rails" command falls back to the original system rails code on the Mac.
For mine, the 'which rails' command in a normal terminal returns
/usr/bin/rails
But after launching Tokaido's shell, 'which rails' gives this path:
/Users/charlesross/.tokaido/Gems/2.2.0/bin/rails
Out of nowhere Rails wasn't currently installed but, what fixed it was
rvm use ruby-2.6.0
...and verified my path in .bash_profile
export PATH="$PATH:$HOME/.rvm/bin"
I was having this problem today. I haven't 100% solved it, but in new tabs I can do rvm use 2.5.5 and then rails -v works fine.
➜ my-repo git:(next_release) ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
➜ my-repo git:(next_release) rails -v
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.
➜ my-repo git:(next_release) rvm use 2.5.5
Using /Users/amberwilkie/.rvm/gems/ruby-2.5.5
➜ my-repo git:(next_release) rails -v
Could not find rake-12.3.3 in any of the sources
Run `bundle install` to install missing gems.
➜ my-repo git:(next_release) bundle install
I was looking through the source and found another error message that suggested the user run the following command.
I ran the command and everything now works. None of the suggestions above worked for me. Run the command from inside your newly created Rails app.
gem pristine --all
Here is how it worked for me:
Intall rvm in mac by following the mac installation instruction
rvm install ruby
gem install rails
rails --version
For me ( MacOS Monterey, rbenv) adding rails version to gem install command get the problem resolved.
you can find a specific version of rails that matches to your ruby from this link and replace the VERSION .
gem install rails -v VERSION
rbenv rehash
after successful installation, then rails should be added to /Users/your_user/.rbenv/shims
Also plz check that your shims directory should be the first element of your path.
➜ ~ echo $PATH #
/Users/ario/.rbenv/shims: ...
I was following along with the Odin Project ruby-on-rails course by
installing rbenv,
adding eval "$(rbenv init -)" to ~/.zshrc
installing rails gem
attempting to run rails new my_first_rails_app
But I had forgot to run source ~/.zshrc after editing the file, so I was seeing the error:
Rails is not currently installed on this system.

Resources