How to reset some Ruby Gem files without git? - ruby-on-rails

I have made some modifications to some gem files that's not tracked by git. How do I reset the gem files to it's used version in console (with bundler?) ?
I'm also using Ruby on Rails.

You can uninstall the gem
gem uninstall gem-name
And then do a
bundle install
should be the easiest solution

Related

Running a ruby on rails app locally - Different versions of ruby

I'm using RVM to manage the different ruby versions I have. One particular application is using an older ruby version (2.3.1), and I've noticed that, once I've changed to that version and run rails server on it, it doesn't work because I'm required to change a whole cascade of Gems or other files, such as nokogiri, to make it run.
Generally, from what I've read online, I should just do a simple bundle install to do all of this before running rails server. However, it doesn't work as there are more conflicting things in this file, specifically that the versions are hard coded into it.
Based on this, how can I run this app on my local server, if the above steps I've done, just doesn't work? I'm using Ubuntu, if that helps.
You're dealing with what is known as dependency issues. The point of Gemfile and Gemfile.lock is to insure that there will be no dependency issues for the application and bundle install will handle that. However it is common for versions to be set in the Gemfile to lock to a specific major release version which might allow for minor version updates. This will look something like:
#Gemfile
gem 'rails', '4.2.10'
gem 'pg', '0.20.0'
gem 'after_party', '~> 1.10' #minor version updates will run here
gem 'kaminari', '~> 1.1'
ruby '2.3.6'
This ia a brief example. Now when you run bundle install it will make sure everything is compatible with these versions. While running bundle update will only update the versions with ~> before the version and will upgrade only minor semantic versions as they are not supposed to have breaking changes.
So, why is your app not working? Well the Gemfile should have contained a ruby version. RVM should determine your ruby version in .ruby-version file in base of your rails app and should match the version in Gemfile. If you need to upgrade your ruby version bundler will help insure all your gems are compatible with that version and with each-other. You'll first need to upgrade your ruby version with RVM, then set it in Gemfile.
However, there is no guarantee that out of date gems will be compatible. That's the whole point of locking them so that you know which versions are stable at a give point in time. Updates / upgrades to gems have to be tested for compatibility which can sometimes be a project.
Also see Rails Bundle, gems conflicts, best way to solve it
You can create a .rvmrc file or .ruby-version and .ruby-gemset files for isolating gems for your projects. Here's the official documentation on that - https://rvm.io/workflow/projects#project-file-ruby-version
you can add
echo '2.3.1' > .ruby-version and echo 'newgemset' > .ruby-gemset into working folder
then run
cd ./
rvm install ruby-2.3.1
gem install bundle
bundle install

upgrading rails app from 5.0.0.rc2 to 5.0.0

I am a newbie so please bear with me :)
I am currently working on my personal project running on rails 5.0.0.rc2. How can I best upgrade my project to use the latest version 5.0.0?
I did some research and found that I could just easily change the rails gem in Gemfile and run 'bundle update rails'. I don't know if this is the best way, but if it's not, what's the best way?
Thanks!
Go to your Gemfile, check gem 'rails' and set it's version like this
gem 'rails', '5.0.0'
the use bundle to install it by running
bundle install
or
bundle
you may encounter some dependencies that require you to run
bundle update
Changing the rails version in the Gemfile would be enough. Also be sure to check out railsdiff.org for changes in the project directory (config files, etc.)

What is the most easy way to install gem?

I need to uninstall a gem "rubyzip 1.1.0" and install the older version "rubyzip 0.9.9"
I need to enter in a specific folder in ssh to do this?
I need upload some file to sftp or I can do a command with some url?
If there is a very simple way even I am very grateful.
Take a look at your Gemfile and look for the line gem 'rubyzip'.
Change this line to: gem 'rubyzip', '0.9.9'
Now run bundle install from your application root directory to fetch and install the downgraded gem (and all of its dependencies).
Done.

Could not find gem 'spree-paypal-express' with spree 1.1.1

Hi I have installed and working Spree 1.1.1. and want to integrate PayPal to the engine. and when i am trying to install 'spree_paypal_express' the console is showing the below message please help me out.
Could not find gem 'spree-paypal-express (>= 0) x86-mingw32' in the gems available on this machine.
There are a few possible issues with this.
First, there may be an issue with your Gemfile. For example,
-- the gem may not be in the gemfile,
-- you may have misspelled the name of the gem in your gemfile
-- you may have extra whitespace in the gem name (e.g., gem 'spree-paypal-express ' <- note extra space)
Here are some things you can try (after checking the above first to make sure your Gemfile is correct):
Remove all your gems (go to the gems folder of your ruby, remove the specifications folder and the gems folder -- or create a new gemset using rvm)
gem list should be more or less empty
gem install bundler
And try to bundle install again from scratch.
I have manually downloaded zip folder from github repository and extracted.
by going in to the directory run gem build spree_paypal_express.gemspec
then it will generate some files in which spree_paypal_express-1.1.0.gem will be one of them.
so later run gem install spree_paypal_express-1.1.0.gem
then you are ready to go... you can check by gem list

rails gem programming - How do I try it before pushing to gemcutter?

I'm developing a new gem (fork of nifty-generators).
Right now my "deployment" consists on the following:
I make changes on the gem's source code
I commit to github
I update the gemspec lower numer (i.e. go from 0.1.1 to 0.1.2)
Build the gem and push it to gemcutter (gem build, gem push)
Install the new gem (sudo gem install mygem)
Then y try the new gem.
I'm sure there must be a more correct way of doing things. Right now, I'm uploading to gemcutter so that I can test my gem.. and that doesn't feel right.
What is the best way to "test your gem before uploading to gemcutter"?
Once you have your gemspec, you can run gem build yourgem.gemspec. That will produce a .gem file for you to install....try the following commands out to verify it:
gem install --local
gem spec
gem unpack
You have to push a built gem to RubyGems.org anyway, so you're pretty much there :)
if you're using jeweler, try this
rake install
(rake --tasks will tell you more)
launch all test unit or rspec test.
You can try in our project after install it on your system.

Resources