What is the most easy way to install gem? - ruby-on-rails

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.

Related

Use additional gem in deployment

does anyone have any idea how to add ruby gems if Gemfile.lock exists?
I’m using an application from an apt package but I want to add my custom gem.
In the Gemfile it says:
# Want to extend Zammad with additional gems?
# ZAMMAD USERS: Specify them in Gemfile.local
# (That way, you can customize the Gemfile
# without having your changes overwritten during upgrades.)
But if I create the Gemfile.local with my Gem the Application couldn start.
You are trying to install in deployment mode after changing
your Gemfile. Run bundle install elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the / opt / zammad / Gemfile freeze
by running bundle install --no-deployment.
The list of sources changed
The dependencies in your gem file changed
You have added to the Gemfile:
mySpecialGem
I used to be able to do this with bundle install --no-deployment , but when I do that I always get the same message
Are you installing the gem as:
gem "gem_name", path: "/Users/Matthies/gem_location"
Could you post what your Gemfile looks like?
the gemfile from the original package is
https://github.com/zammad/zammad/blob/stable/Gemfile
in my Gemfile.local is this:
gem 'gem_name', git: 'https://github.com/myname/mygem'

How to reset some Ruby Gem files without git?

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

Install gems via ftp

Can you install your ruby gems via ftp? I mean just copy your local gem directory /var/lib/gems/1.9.1/gems and put it online with filezilla in the ruby>gems>gems directory.
The reason I want to do this is because with cPanel it gives me errors when trying to install some gems (like permission errors, some require ruby >=1.9.2 but I already have ruby 1.9.3). So is there a simple way?
Thanks!
Instead of copying your system's gem which may be ruby version specific, you could place all the required gems sources in your application's lib directory and reference them in your Gemfile. Not that you cannot place these sources in other directories.
Place gem source in your local application e.g. #{Rails.root}/lib/my_gem and update your Gemfile to reference the gem using:
gem "my_gem", path: "lib/my_gem"
Then run bundle install to install the sourced gem in your application.
and you can run
gem server
then add the source
http://some.ip:8808
there you'll have shared the gem installed in that system

How do I add a local custom gem with RVM or otherwise?

I have to add a custom gem which is downloaded onto my local machine. How do I get it installed with Rails? I also have RVM installed. I tried pasting it into the gems folder but it doesn't get installed.
I believe to install a gem you need to run the setup.rb file but this gem doesn't seem to have that present. Any pointers to how to get this gem installed?
It's very important because I think this gem has dependencies and is stopping my project from running.
Another option, in addition to #shingara's, is you can still add it to your Gemfile, but it will depend on everyone in your project team having the gem in the same location. Then you can do:
gem 'my_gem', '0.1.2.3', :path => '~/my_projects/my_gem_folder/'
And when you bundle, it'll pull and install from there.
If you're working on something by yourself, you can do this without worry that someone else who pulls down that project won't have that gem in the same location.
EDIT In addition to your comment for #shingara's answer, this works for not pointing straight to a .gem file, but to a folder that your gem resides in.
You can install a gem by this path
gem install path/my_gem.gem

Install a gem from a downloaded tar or zip

First let me say I cannot do gem install, I don't know why. Probably because I live in China and the firewall random things.
So I have to locally install gems. For example, i want to install this gem riddle. But this gem downloads as a tar or zip and when i open it it is a folder not a .gem file.
So what to do?
You can do gem build whatever.gemspec inside of the directory that you untar/unzip -- that will produce a .gem file, then do gem install whatever.gem.
You need to be at the directory where you unzip the gem file for example
C:\railsinstaller\ruby2.2.0\lib\ruby\gems\2.2.0\gems> gem install rails-5.0.0.1.gem
and that's it - you are done downloading and installing Rails.
To avoid the gem build step, and to always run the actual code, bundler can install from a local path:
gem 'pry', path: './pry'
in a Gemfile.
... where ./pry would be the clone of your repository.
Simply run bundle install once, and any changes in the gem sources you make are immediately reflected. With gem build pry / gem install pry/pry.gem, the sources are still moved into GEM_PATH and you'll always have to run both gem build pry and gem update again if you make changes.

Resources