I had RVM and RBENV installed on my computer and I decided to keep only RBENV So I followed this setup
I am on mac with high sierra
The first trouble I am facing is that ruby -v displays nothing.
I know that my ruby version is ok because of ohmyzsh [2.4.4]
When I try to run this command gem install rake bundler rspec rubocop pry pry-byebug hub colored octokitnothing happens... I can't install bundler nor rails.... I am not supposed to use the sudo... What could be wrong and how could I find fix this?
I can't even launch irb and gem install bundlerdoes nothing
there must be a conflict somewhere?
I ran this dignostic:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 320 100 320 0 0 858 0 --:--:-- --:--:-- --:--:-- 860
--- PATH ---
./bin:/Users/bill/.rbenv/shims:/usr/local/opt/rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/ImageMagick/bin:/usr/local/sbin
--- RBENV ---
rbenv is /usr/local/opt/rbenv/bin/rbenv
rbenv is /usr/local/bin/rbenv
system
* 2.4.4 (set by /Users/bill/.rbenv/version)
--- RUBY ---
ruby is /Users/bill/.rbenv/shims/ruby
ruby is /usr/bin/ruby
ruby is /usr/local/bin/ruby
--- GEM ---
gem is /Users/bill/.rbenv/shims/gem
gem is /usr/bin/gem
gem is /usr/local/bin/gem
--- POSTGRES ---
postgres is /usr/local/bin/postgres
postgres (PostgreSQL) 10.5
2018-09-11 17:04:51.406 CEST [30591] FATAL: database files are incompatible with server
2018-09-11 17:04:51.406 CEST [30591] DETAIL: The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.5.
See my .zshrc
ZSH=$HOME/.oh-my-zsh
# You can change the theme with another one:
# https://github.com/robbyrussell/oh-my-zsh/wiki/themes
ZSH_THEME="robbyrussell"
# Add ruby version on prompt (float right)
if [ -x "$(command -v rbenv)" ]; then RPS1='[$(ruby_prompt_info)]$EPS1'; fi
# Useful plugins for Rails development with Sublime Text
plugins=(gitfast brew rbenv last-working-dir common-aliases sublime zsh-syntax-highlighting history-substring-search)
# Prevent Homebrew from reporting - https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
export HOMEBREW_NO_ANALYTICS=1
# Actually load Oh-My-Zsh
source "${ZSH}/oh-my-zsh.sh"
# Rails and Ruby uses the local `bin` folder to store binstubs.
# So instead of running `bin/rails` like the doc says, just run `rails`
export PATH="./bin:${PATH}:/usr/local/sbin"
# Store your own aliases in the ~/.aliases file and load the here.
[[ -f "$HOME/.aliases" ]] && source "$HOME/.aliases"
# Encoding stuff for the terminal
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export BUNDLER_EDITOR="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
export BUNDLER_EDITOR="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
export BUNDLER_EDITOR="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
eval "$(rbenv init -)"
Also ran this diganostic:
You seem to have multiple rbenv installs in the following locations.
Please pick just one installation and remove the others.
/usr/local/opt/rbenv/bin/rbenv
/usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20180822)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: %
here is a screenshot of my ~maybe something needs to be removed ? what about that .rvmrc it says rvm_auto_reload_flag=1
rvm_auto_reload_flag=2
EDIT
I am opening the folders and files:
in .profileit says:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Clarify the "nothing happens"
~ gem install rake bundler rspec rubocop pry pry-byebug hub colored octokit
➜ ~
I fixed with:
brew update
brew upgrade
brew uninstall ruby
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.
I have an ubuntu machine and I am trying to install rubygems using RVM by following this guide:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
When I run the command rvm rubygems current or even the command rvm rubygems latest I get the following error:
fl4m3ph03n1x: ~ $ rvm rubygems current
system - #downloading rubygems-2.4.8
system - #extracting rubygems-2.4.8.....
system - #removing old rubygems.........
$LANG was empty, setting up LANG=en_US.utf8, if it fails again try setting LANG to something sane and try again.
system - #installing rubygems-2.4.8.
Error running 'env GEM_HOME=/home/fl4m3ph03n1x/.rvm/gems/system#global GEM_PATH= /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby -d /home/fl4m3ph03n1x/.rvm/src/rubygems-2.4.8/setup.rb --no-document',
showing last 15 lines of /home/fl4m3ph03n1x/.rvm/log/1437602750_system/rubygems.install.log
[2015-07-22 22:05:50] /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby
current path: /home/fl4m3ph03n1x/.rvm/src/rubygems-2.4.8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/fl4m3ph03n1x/.rvm/bin
command(7): env GEM_HOME=/home/fl4m3ph03n1x/.rvm/gems/system#global GEM_PATH= /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby -d /home/fl4m3ph03n1x/.rvm/src/rubygems-2.4.8/setup.rb --no-document
env: /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby: No such file or directory
At first I thought the error was due to the --no-document flag, but after reading and trying this discussion on github, nothing changed.
I also checked this stackoverflow discussion but it doesn't seem to be applicable to my case because I have a fresh installation (no manually installed packages nor anything).
Over all I tried using commands like rvm get head and rvm stable but nothing seems to work.
What am I missing? Could this be a permission's problem somehow?
EDIT:
This is the result of rvm list:
rvm rubies
ruby-2.2.1 [ x86_64 ]
# Default ruby not set. Try 'rvm alias create default <ruby>'.
# => - current
# =* - current && default
# * - default
I had ruby installed, but turns out it was not set in rvm.
To fix this first I tried using rvm use ruby --default, but I got the infamous "rvm is not a function" error.
To fix this, first run bash --login and then then rvm use ruby --default.
Once these steps are complete you can proceed with rubygems installation.
After running any homebrew command I get the same error over and over......
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- extend/module (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/local/Library/Homebrew/global.rb:1:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /usr/local/Library/brew.rb:16:in'
The best idea – use rvm.
First of all reinstall homebrew.
Then install rvm:
\curl -sSL https://get.rvm.io | bash -s stable
Then you need to provide ruby version and gemset. Go to app folder and create files .ruby-version and .ruby-gemset (including dot). Then add version and gemset in this files. Simple way to do it via console. In console, go to app directory, then:
echo ruby-2.1.3 >> .ruby-version
echo gemsetname >> .ruby-gemset
Of course, provide ruby version that you need. Gemsetname is often equal to app name. So, if your app is called coolapp, your gemsetname should be coolapp. Smth like this:
echo coolapp >> .ruby-gemset
Now, leave app directory and try to enter it again via console:
cd /path/to/your/app
RVM will generate everything you need automatically and you will see stmth like this:
ruby-2.1.3 - #gemset created /Users/username/.rvm/gems/ruby-2.1.3#coolapp
ruby-2.1.3 - #generating coolapp wrappers..........
Boya! This approach will provide same version and gemset name for every developer because files will be included in git. And that will decrease bug level. Everything you need from this moment, just use:
bundle install
And everything should goes right!
I would recommend using rbenv or rvm to manage your development Ruby version and gems. Editing OS X's system Ruby could cause difficult-to-diagnose problems.
Also, you shouldn't need to sudo to install gems. You need to be very careful when sudoing a command since, again, it could cause difficult-to-diagnose problems with the operating system down the road.
So, I'd recommend you re-install homebrew, then install rbenv from git, then gem install away.
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.