RVM doesn't seem to be automagically creating a new gemset for a newly cloned git based rails project as it did for other projects when cding into the project folder. I get this message:
ruby-2.2.4 is not installed.
I am using ruby-2.3.1 and have set it as the default and that is the only ruby version I installed using rvm. Why am I getting that error message? I am on a MAC (Sierra OS) if that matters.
It started happening randomly as soon as I cloned a new project. I don't see ruby-2.2.4 being mentioned in the gemfile or the gemspec. Where is it picking it from?
If you paste the whole error message you get when trying to run bundle install it'll be easier to say for certain, but I'm assuming one of the gems in your gemfile requires Ruby version 2.2.4.
Just type in
rvm install 2.2.4
Then run bundle install again and all should be well, assuming no other errors.
You may need to switch which version of Ruby you're using based on which project you're in, just use
rvm use 2.4.0
rvm use 2.2.4
etc.
Related
I have a friend's website code, which is in Ruby on Rails.
I have tried to install RoR on my Mac using instructions at gorails.com
OS : Mac Mojave
ruby -v : ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin18]
rails -v :
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem railties (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/bin/rails:22:in `<main>'
What I tried : I installed ruby, and then rails, using gorails tutorial, and kept getting errors stating version number mismatch.
Keep in mind that creating a new app, worked, but trying to run this existing code is a problem.
So then I uninstalled everything and updated the version using rvm, and since then I am getting this error.
When I cd into the webapp folder and run bundle install, I get errors, such as:
zsh: /Users/abc/.rvm/gems/ruby-2.2.3#hs/bin/bundle: bad interpreter: /Users/abc/.rbenv/versions/2.5.3/bin/ruby: no such file or directory
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
RVM are available at rvm.io/packages/openssl.
This project uses a PostgreSQL database, which I have setup already.
If required, I can share the gemfile of this project too.
What is the best way to get this project working?
Am I missing something crucial?
You can't run RVM and RBENV on the same machine. Pick one and remove the other. You're probably best to uninstall both and then pick one, start over.
Uninstall RBENV instructions here or in your case probably brew uninstall rbenv
Uninstall RVM see How can I remove RVM (Ruby Version Manager) from my system?
Close all terminals and then start a new one.
Install RVM see https://rvm.io/rvm/install
Then go to your project, make sure you have the correct ruby version needed by your project. If not, you will need to install with rvm install 2.5.1 for example.
Then run
rvm use 2.5.1 #or some other version
Then you should be able to run bundle install
The rest of the instructions in your link should be ok.
My application was running fine with Ruby 2.2.4, until running a test gave me an error saying "the ruby version you're using is outdated/buggy".
So I updated and used Ruby 2.3.0 as the default for my application. After that I got an error saying "could not find bundler".
I already had bundler, so why does updating the Ruby version require reinstalling bundler into my application?
(I am learning Ruby-on-Rails, so treat me as a beginner.)
Each copy of Ruby installed on a computer has its own set of installed gems. One reason that gems aren't shared between installations of Ruby is that some gems include compiled native code, and the compiled output might be different for different versions of Ruby.
bundler is a standalone gem, not part of Ruby, so whenever you install a new Ruby you have to install bundler in that Ruby.
This is independent of whether you're using a Ruby version manager (chruby, rbenv, rvm, etc.); if you install a new Ruby, it needs its own set of installed gems.
Whenever you install a new version of Ruby with RVM it creates a wrapper with what they call gemsets. Gemsets are not shared between ruby version so therefore when you installed your new Ruby 2.3.0 it installed without any gems.
To fix this problem simply install bundler by running gem install bundler.
Once that's done, you should have it available for your new installation of Ruby.
I also had faced such issue. First I run this with selected RVM version.
gem install bundle
Then you should run:
bundle install
In your project directory.
Please let me know if you have any confusion.
How do I safely upgrade my ruby on rails app to use a new ruby version, using rvm?
Suppose your app is my_app and you are using ruby version a.b.c and want to go to ruby version x.y.z.
Step 0
Before starting, make sure you have the up to date version of rvm
rvm get stable
rvm reload
Step 1
First if you do not have a gemset for your current ruby version create one and make it the default. This gives you an easy way to go back if your upgrade breaks your tests. If you do not want to do this, go to step 2.
rvm gemset create my_app_abc
The switch to that gemset and install the gems into that gemset, and make it the default gemset for the directory
rvm a.b.c#my_app_abc
bundle
rvm --ruby-version use a.b.c#my_app_abc
Step 2
Now upgrade to the new ruby version and create a gemset for it.
rvm install x.y.z
rvm use x.y.z
rvm gemset create my_app_xyz
rvm x.y.z#my_app_xyz
It is considered best practice to specify the ruby version in your Gemfile so
make sure you have ruby 'x.y.z' at the top of your Gemfile. Then
gem install bundle
bundle
This is where the fun can start, you may get errors at this point and use a combination of following the error instructions or googling for help, etc to solve them. When you can bundle successfully, then run all your tests.
When your tests have all passed, then you have successfuly upgraded. If you get stuck, you can go back to your old installation, using rvm a.b.c#my_app_abc.
Once you are happy with your new installation then do
rvm --ruby-version use x.y.z#my_app_xyz
to make this the default setup for this app. This means when you change into this app from other projects, it will automatically load ruby version x.y.z and the corresponding gemset.
According to this blog, if you always precede commands by bundle exec you do not need to use gemsets. In that case, you would simply do
rvm --ruby-version use x.y.z
I'm currently working on a project which was changed from ruby version 2.0.0 to ruby verion 2.1.1,
i'm using rvm for maintaining my ruby versions. After installing ruby 2.1.1, I ran gem install bundler which installed version 1.6.2, doing so I had copied a specific gemset version to a newly created one for version 2.1.1 after which when running gem list on, it displayed all the gems, and when I tried to run the app it started throwing errors.
So when I ran bundle install again it created a separate folder parallel and installed the gems there. My question is why does this happen, is it a new feature of bundler 1.6.2'?
Initially I had my bundler version to 1.5.2.
Any input on this will be really helpful.
Thanks.
Found this post which explains clearly, the reason was my config file was corrupted.
we have to remove .bundle/config file and bundle install again.
rm -r .bundle/config
bundle install
click here for more information.
Thanks.
My guess is you have two different bundlers tied to a different RVM gemset, even if you tried to install the newest globally.
In the future you may consider using :
bundle install --path .bundle
to install your gems in a consistent manner, always in the same .bundle folder, no matter what RVM gemset you're using.
I recently started learning Rails using Ruby 1.9.3p385, and I'm trying to develop a small project with it.
I'm using Linux so I installed Ruby using RVM.
I developed a few pages, following some tutorials. I would like to upgrade my project to use Ruby 2.0.0. What do I have to do?
I installed Ruby 2.0.0 with RVM:
rvm install 2.0.0
Everything seems OK, so I tried to use it:
rvm use 2.0.0-p247
But when I try to run my Rails server using rails server, I get the following message:
bash: rails : command not found
I've read the RVM documentation about upgrading Ruby but I don't really understand what it does; I'm afraid of breaking everything.
Does it will upgrade my project in a way it will use Ruby 2.0.0 or what should I do?
Next, I will want to upgrade also to Rails v4.
Your gemset which comes with new Ruby version is empty. Try this:
gem install bundler # this will install bundler
bundle # this will use bundler to install required gems
rails server
Did you run rvm use 2.0.0-p247 or did you use rvm use 2.0.0-p247 --default? The later will set Ruby v.2.0 as the default for your system. Failure to do that will revert your Ruby to whatever RVM's default is the next time you log into your system or open a new terminal window.
When RVM installs a new version of Ruby, it installs only the default gems. It CAN upgrade a Ruby to another version, and optionally install the existing gems as it does so, but that's not what you asked it to do: rvm install 2.0.0 only installs Ruby. At that point you have to install the other gems you need, which would include Rails.
My general practice when installing various versions of Ruby and the gems I like is to use two command-line pipes to dump my existing gems, then (re)install them. First I switch to an existing Ruby whose gems I want to duplicate, then run:
gem list | cut -f1 -d' ' > ~/gem_list
Then I switch to the newly installed one, and run this:
xargs gem install < ~/gem_list
This does a completely clean install of the gems, outside of RVM's commands.
Why? Habit. Paranoia based on some "experiences" I had in the past with RVM.
Once that's all done and I have brand-spanking-new Ruby and gems, I'll proceed with running bundler or other housekeeping chores.
when you install a new ruby version, you have to reinstall all the gems for that version. start of by installing bundler first. Then run bundle in your rails root directory. When you encounter no errors, you're good to start the rails server. Good luck!
run bundle install on the application root, you need to reinstall all your dependencies for the new version of Ruby.