Rails cannot load such file -- stringio (LoadError) - ruby-on-rails

My Rails app was working fine and then I decided to try to update it from 4.0 to 4.2 so I could put it on Heroku. The guide I was following said to update RubyGems so I ran this command:
$ gem update --system
Got this warning:
Warning! `PATH` is not properly set up, '/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin'
is not at first place, usually this is caused by shell initialization
files - check them for 'PATH=...' entries, it might also help to re-add
RVM to your dotfiles: 'rvm get stable --auto-dotfiles', to fix temporarily
in this shell session run: 'rvm use ruby-2.0.0-p353'
I ignored the warning and went to the next step in the guide.
I tried to create a gemset:
$ rvm use 2.0.0p353#rails4.0.2_myapp --create
Then I decided to not update because I was scared of breaking my app. So I just tried to push the app to Heroku without updating.
I ran
$ heroku login
$ heroku create
$ git push heroku master
It failed to push to Heroku because the slug size was too big. I went to fix it and then I started getting this error:
/Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:16:in `require': cannot load such file -- stringio (LoadError)
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:16:in `<top (required)>'
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:1228:in `require'
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:1228:in `<module:Gem>'
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:115:in `<top (required)>'
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
TLDR: App was working. Then I ran these commands:
$ gem update --system
$ rvm use 2.0.0p353#rails4.0.2_myapp --create
$ heroku login
$ heroku create
$ git push heroku master
Now I receive that LoadError error and can't run my app. How can I fix this? I'm assuming something broke when I ran
$ gem update --system
I read this question: no such file to load -- rubygems (LoadError), and someone says to check if you have two ruby versions installed so I ran:
$ which -a ruby
/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/usr/bin/ruby
but I don't know what to do after or if it even matters since I only ran those above commands after my app was working fine.
Here are my versions if it matters:
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]
I can't run rails -v because I get the LoadError. But before the error I got this:
$ rails -v
Rails 4.0.2
Before error (I think this updated to a newer version after I ran the update command):
$ gem -v
2.4.8
EDIT
After trying to switch to old version of rubygems:
$ rvm rubygems 2.4.8
I got:
Warning! PATH is not properly set up, '/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin'
is not at first place, usually this is caused by shell initialization
files - check them for 'PATH=...' entries, it might also help to
re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles', to fix
temporarily in this shell session run: 'rvm use ruby-2.0.0-p353'.
ruby-2.0.0-p353 - #downloading rubygems-2.4.8
ruby-2.0.0-p353 - #extracting rubygems-2.4.8.....
ruby-2.0.0-p353 - #removing old rubygems..........
ruby-2.0.0-p353 - #installing rubygems-2.4.8.
Error running 'env GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353#global GEM_PATH= /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -d /Users/devon/.rvm/src/rubygems-2.4.8/setup.rb --no-document',
showing last 15 lines of /Users/devon/.rvm/log/1452506634_ruby-2.0.0-p353/rubygems.install.log
[2016-01-11 05:03:54] /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
current path: /Users/devon/.rvm/src/rubygems-2.4.8
GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353
PATH=/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353#global/bin:/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin:/Users/devon/.rvm/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/tools
GEM_PATH=/Users/devon/.rvm/gems/ruby-2.0.0-p353:/Users/devon/.rvm/gems/ruby-2.0.0-p353#global
command(7): env GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353#global GEM_PATH= /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -d /Users/devon/.rvm/src/rubygems-2.4.8/setup.rb --no-document
And then the stringio error occurs at the end here
EDIT 2:
$ echo $PATH
/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353#global/bin:/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/devon/.rvm/bin:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/tools

My best guess of what's happening:
The PATH warning that you received is because you updated the local rvm 'gem' command using the system ruby (in /usr/bin);
When you created the gemset, rvm fixed the path, but after this RubyGems from your system ruby is being run using your rvm ruby, and I guess the two versions do not match.
The easiest solution would be to completely remove and reinstall rvm:
$ rm -rf ~/.rvm
Reinstall rvm
Re-run bundle install
To confirm this is indeed the problem before deleting rvm, you can temporarily switch /usr/bin (put this first) and /Users/devon/.rvm/gems/ruby-2.0.0-p353/bin (and this after) in your PATH. At this point, gem -v should still give you 2.4.8, and /Users/devon/.rvm/gems/ruby-2.0.0-p353/bin/gem -v should work fine and give you the newer version of RubyGems.
Alternative solution
Something else (simpler) you could try is to force rvm to reinstall the older version of RubyGems, and then update it again (if required):
rvm rubygems 2.4.8
Have a look here for more details on managing RubyGems with rvm.

Related

Received odd RVM error in workspace, now rails commands aren't working

I just logged into my Ubuntu workspace on Cloud9. Upon logging in I saw an error.
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does
that too, you can ignore these warnings with 'rvm rvmrc warning ignore
/home/ubuntu/workspace/Simutronix/Gemfile'. To ignore the warning for
all files run 'rvm rvmrc warning ignore allGemfiles'.
Which I've not seen before and wasn't occurring when I last used the workspace. I then attempted to run the Rails server.
rails server -b $IP -p $PORT
I got an error message back.
bash: rails: command not found
I then tried to run bundle install which also came back with command not found.
ruby -v returns ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux].
What's likely to have happened to cause this to happen in between logins and what can I do to fix it?
Looks like Ubuntu can't find your Rails installation. Make sure you have Rails installed on your workspace by typing:
rails -v
If it is properly installed, It should return something like
Rails 5.0.2
(depending upon your Rails version.)
If you don't have Rails installed, you can install it by typing
gem install rails
You can append --no-doc to the above command if you don't want it to install documentation, thereby speeding up the installation process (That's totally up to you, though. It won't affect your installation in any other way. I promise!)
If this doesn't solve your problem, please update your answer with your Gemfile.
Likely the Ruby version defined in your Gemfile and/or .ruby-version changed, which means you will have to install bundler and bundle the gems again. Running this should solve the issue:
gem install bundler
bundle install

rails s not working

My rails command suddenly stopped working
I am just typing command
rails s
and getting error
bash: /usr/local/bin/rails: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory
and command
ruby -v gives me
ruby 1.9.1p431 (2011-02-18 revision 30908) [i686-linux]
any help?
thanks in advance
Please take care of your PATH variable, I had to remove also all ruby and rvm entries from .bashrc, .profile and .bash_profile. Maybe somewhere there your old ruby is specified.
Additionally: On my MACOSX_10.6.8 I just had problems updating ruby-1.9.3p125 to the newest version. So I did everything from scratch and removed (rvm remove 1.9.3p125) and also did rvm implode to remove the ~/.rvm directory completely.
Check How can I remove RVM (Ruby Version Manager) from my system?
Later on:
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 1.9.3
After doing that, everything worked just fine!

Cannot find Ruby or Rails in my computer after installing Heroku

I just started to learn Rails from railstutorial.org. After installing Rails I cerated an app, set up git, installed Heroku gem, and uploaded SSH key to heroku.
After that, I turned off my computer and a few hours later I came back to continue with the next steps. First I ran heroku create --stack cedar.
Then,
git push heroku master I get the following error message:
[~ (master)]$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Same thing is happening for commands like rails heroku gem etc.
Also, I cannot find neither Ruby or Rails in my system. When I ran ruby -v I get
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
Is this happening because I am running Ruby 1.9.3p125? Please help.
just type
rvm gemset list
rvm use 1.9.3#(you_gemset) --default
EDIT: i've looked this tutorial, and there he's created gemset: rails3tutorial2ndEd
then just type: rvm use 1.9.3#rails3tutorial2ndEd --default
You probably haven't set ruby 1.9.3 as your default ruby with rvm. You can do this by typing in the command line:
rvm use 1.9.3 --default
This should solve your problem.

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.

no such file to load -- rubygems (LoadError)

I recently installed rails in fedora 12. I'm new to linux as well. Everything works fine on Windows 7. But I'm facing lot of problems in linux. Help please!
I've installed all the essentials to my knowledge to get the basic script/server up and running. I have this error from boot.rb popping up when I try script/server. Some of the details I'd like to give here:
The directories where rails, ruby and gem are installed,
[vineeth#localhost my_app]$ which ruby
/usr/local/bin/ruby
[vineeth#localhost my_app]$ which rails
/usr/bin/rails
[vineeth#localhost my_app]$ which gem
/usr/bin/gem
And when I run the script/server, this is the error.
[vineeth#localhost my_app]$ script/server
./script/../config/boot.rb:9:in `require': no such file to load -- rubygems (LoadError)
from ./script/../config/boot.rb:9
from script/server:2:in `require'
from script/server:2
And the PATH file looks like this
[vineeth#localhost my_app]$ 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="/usr/local/bin:/usr/local/sbin:/usr/bin/ruby:$PATH"
I suppose it is something to do with the PATH file. Let me know what I need to change here. If there are other changes I should make, please let me know.
I have a hunch that you have two ruby versions. Please paste the output of following command:
$ which -a ruby
updated regarding to the comment:
Nuke one version and leave only one. I had same problem with two versions looking at different locations for gems. Had me going crazy for few weeks. Put up a bounty here at SO got me same answer I'm giving to you.
All I did was nuke one installation of ruby and left the one managable via ports. I'd suggest doing this:
Remove ruby version installed via ports (yum or whatever package manager).
Remove ruby version that came with OS (hardcore rm by hand).
Install ruby version from ports with different prefix (/usr instead of /usr/local)
Reinstall rubygems
I had a similar problem on Ubuntu due to having multiple copies of ruby installed. (1.8 and 1.9.1) Unfortunately I need both of them. The solution is to use:
$ sudo update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/ruby1.8 50 auto mode
1 /usr/bin/ruby1.8 50 manual mode
2 /usr/bin/ruby1.9.1 10 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.
After doing that bundle install succeeded.
OK, I am a Ruby noob, but I did get this fixed slightly differently than the answers here, so hopefully this helps someone else (tl;dr: I used RVM to switch the system Ruby version to the same one expected by rubygems).
First off, listing all Rubies as mentioned by Eimantas was a great starting point:
> which -a ruby
/opt/local/bin/ruby
/Users/Brian/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
/Users/Brian/.rvm/bin/ruby
/usr/bin/ruby
/opt/local/bin/ruby
The default Ruby instance in use by the system appeared to be 1.8.7:
> ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10]
while the version in use by Rubygems was the 1.9.2 version managed by RVM:
> gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /Users/Brian/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
So that was definitely the issue. I don't actively use Ruby myself (this is simply a dependency of a build system script I'm trying to run) so I didn't care which version was active for other purposes. Since rubygems expected the 1.9.2 that was already managed by RVM, I simply used RVM to switch the system to use the 1.9.2 version as the default:
> rvm use 1.9.2
Using /Users/Brian/.rvm/gems/ruby-1.9.2-p290
> ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.3.0]
After doing that my "no such file" issue went away and my script started working.
I would just like to add that in my case rubygems wasn't installed.
Running sudo apt-get install rubygems solved the issue!
Try starting the project with:
./script/server
instead of script/server if you are using ruby 1.9.2 (from strange inability to require config/boot after upgrading to ruby 1.9.2)
In case anyone else is googling this problem: I was able to fix mine by finding the elusive "rubygems" folder that I wanted to use and adding it to my $RUBYLIB environment variable.
find / -name "rubygems" -print
Once you find it, add the parent directory to your environment. In bash, like so:
export RUBYLIB=/path/to/parent
Now if you run gem, it should pick up the right library directory, and you're off and running.
I had a similar problem, simply running a trivial ruby script that just required the gem i wanted...got that error message. When I changed the incantation from:
ruby test.rb
to
ruby -rubygems test.rb
Seemed to work.
I had a similar problem and solved that by setting up RUBYLIB env.
In my environment I used this:
export RUBYLIB=$ruby_dir/lib/ruby/1.9.1/:$ruby_dir/lib/ruby/1.9.1/i686-linux/:$RUBYLIB
If you have several ruby installed, it might be sufficient just to remove one of them, on MacosX with extra ports install, remove the ports ruby installation with:
sudo port -f uninstall ruby
I also had this issue.
My solution is remove file Gemfile.lock, and install gems again: bundle install
gem install bundler
fixed the issue for me.
This is the first answer when Googling 'require': cannot load such file -- ubygems (LoadError) after Google autocorrected "ubygems" to "rubygems". Turns out this was an intentional change between Ruby 2.4 and 2.5 (Bug #14322). Scripts that detect the user gems directory without taking into account the ruby version will most likely fail.
Ruby 2.4
ruby -rubygems -e 'puts Gem.user_dir'
Ruby 2.5
ruby -rrubygems -e 'puts Gem.user_dir'
I have also met the same problem using rbenv + passenger + nginx. my solution is simply adding these 2 line of code to your nginx config:
passenger_default_user root;
passenger_default_group root;
the detailed answer is here: https://stackoverflow.com/a/15777738/445908
Simply running /bin/bash --login did the trick for me, weirdly. Can't explain it.

Resources