Generally, if I need a gem, I put it in the Gemfile and bundle install. However, I don't understand if there is a benefit to downloading the gems locally first with gem install _____. Is there any benefit to this? Does bundle install no longer have to connect to the net in that situation?
Bundler installs the gems located in your Gemfile locally the same as if you ran gem install for each of those gems.
Gem install needed for gems that can be used outside of bundler applications. For example request-log-analyzer need to be installed outside of any apps for be available in command line.
I myself use gem install _______ then i use bundle install --local which doesn't require internet connection if the gem is found locally but will return an error if the gem was not found locally...
I find this method faster in downloading and installing gems, plus if the gems are found locally then i have also the benefit of altering the gemfile and install the gems without having internet connection.
Related
I want to install ruby on rails in offline mode (i.e. without internet connection). So I downloaded railsinstaller-3.2.0.exe from http://railsinstaller.org/en and installed it. By the end, I had ruby installed but in order to have rails installed I ran
gem install rails
and faced these errors: (meaning command needs internet connection)
ERROR: Loading command: install (ArgumentError)
unknown encoding name - CP720
ERROR: While executing gem ... (NoMethodError)
undefined method 'invoke_with_build_args' for nil:NilClass
I mean is there any solution like downloading gems with another computer connected to internet and then copying files in the proper location in the installed directory of gems.
Please help me if you have any idea.
As said in a comment, it's a gem (lib) dependency issue.
You might want to look into installing the bundler gem library to manage dependencies for you, with bundler you would just have to run, bundle install and it would download all the required gems for you including any gem dependencies.
You can install bundler simply, just run
gem install bundler
Then in your rails project directory, just run bundle install.
Often to run a project (like rails for example) you might have to start it with
bundle exec rails start
To install Gem's on a non-internet connect computer you might want to refer to this answer on just that problem.
This is the website where you can find all available ruby gems. Ruby
gems download. Find the one you are interested and download it.
Then move the gem in a directory of your choice and cd into that from
the command prompt. I am using C:/ruby193/bin/pony-1.4.gem
Let's say that the gem we are interested in is the pony gem (smtp
email).
Just type gem install pony-1.4.gem
and you should get it installed manually unless you have a restricted
acc with not adequate administrative privileges.
You can also refer to the official documentation on the matter.
I'm having a problem with the rails
bundle install
command not being able to find a local gemfile.
The gem is located here::
~/.gem/ruby/2.1.5/gems/mygemname-1.5.0.SNAPSHOT
I included the gem in my Gemfile. But when I try to bundle my application, it get this error::
Could not find gem 'mygemname-1.5.0.SNAPSHOT' (>= 0) ruby' in the gems available on this machine.
I can see the gem sitting on my hardrive, but the bundle install command says it doesn't exist. Does anybody have any ideas on what may be going on here?
Thanks for your time.
As I canĀ“t comment yet...
I would check:
- Is it really the .gem folder holding the gem or is it symlinked (I am not confident that symlinks work on bundle install)
- Is rbenv or rvm in the game and is the installed gem installed with one of those or globally?
As the question states - where does the gem install?
Is it installing within the app directory that I'm working in (i.e. user/sites/sample_app)? Or is it being installed on my computer? If the latter where exactly?
Thanks!
gem install process
first download gem and save desktop
1.next step open command prompt and set location that means c:/desktop> gem install --local "gemname"
2.next step com to rails consoler and type $bundle install --local.
3. type the gem name on gem list
I have two questions:
Where do you install your ruby?
Did you use RVM or rbenv?
Now I will explain your question using my situation as an example.
I use RVM to manage rubies on my mac os.
now the ruby install in path
/Users/pin/.rvm/rubies/ruby-2.1.1
and these will be a gems directory under .rvm path. In this directory,
/Users/pin/.rvm/gems
there are many gems group, I have a group named
ruby-2.1.1#global
which is used by the default ruby version.
This is a directory and there will be a gems directory under it.
/Users/pin/.rvm/gems/ruby-2.1.0/gems
In this directory, you will find all of the gems you installed using cmd
bundle install
If you don't use ruby version management tools like rvm or rbenv, you may find the gems
around your ruby path. If you still can't find them, you can post the details of how you
install the rubies and other system configs, so that we can discuss here.
If you are using rvm then its get installed in
/home/user/.rvm/gems/ruby-version#global/ or /home/user/.rvm/gems/ruby-version/
If you are using specific gemset for gems then
/home/user/.rvm/gems/ruby-version#gemset_name/
If you want to know where gem is installed use gem which *gem_name* e.g.:
gem which rails
If you installed your gems with bundle install use bundle show *gem name* e.g.:
bundle show rails
Gems
If you use gem install x, you're adding the gem to the local ruby version on your system. This is a system-wide installation, and will be stored in your rubylib/ruby/gems dir:
The install command downloads and installs the gem and any necessary
dependencies then builds documentation for the installed gems.
Bundler
Using the bundle install command (when you have a Gemfile & use bundler), you basically tell bundler to install the gems relative to your specific applicaiton:
Bundler makes sure that Ruby can find all of the gems in the Gemfile
(and all of their dependencies). If your app is a Rails 3 app, your
default application already has the code necessary to invoke bundler.
If it is a Rails 2.3 app, please see Setting up Bundler in Rails 2.3.
For example, if you have a Rails 3.2 app, and a Rails 4.1 app on your system, using bundler allows you to instal the dependencies (gems) for each app independently
If you use gem install x, it will install the gem for all applications, and should only be used for things like rmagick and the database connection gems
We are deploying our apps as RPM linux packages (with all the dependencies also packaged in RPMs). It turns out that bundler is problematic in this situation and it only complicates our build process - we would like to get rid of it.
Is it possible to run Rails 3 app without it forcing Ruby to use system rubygems? How?
In the book Rails 3 Way there is a statement describing that the easiest way to remove Bundler is to delete Gemfile* files. That's it. It just works.
You could install all gems manually using gem install gemname. In your situation or if you do not have sudo rights it is perhaps recommendable to install the gem files locally in your user directory using
gem install --user-install gemname
You can also install your gems locally with bundler:
bundle install --path ~/.gem
I'm pretty new to Ruby/Rails but I was taking a look at bundler and was wondering how it works exactly. Do you install a full set of gems like normal gem install XYZand then use the Gemfile to pull a certain subset of those gems for use with a specific application? Or do you not install gems normally anymore and just include them in the Gemfile and then do a bundle install to include them all in a bundle that is then used with your application?
Thank you so much for taking the time to answer this, I'm just a little confused on what bundler's functionality is exactly.
-- MAP
These two links explain everything about bundler.
How does bundler bundle
How does bundle require gems
Think of bundler as a package management tool.
From bundle help command:
bundle install # Install the current environment to the system
bundle package # Locks and then caches all of the gems into vendor/cache
So bundle install command will install all gems to the system that are listed in Gemfile as well as their dependencies. If the gem was not previously installed it will grab it from the gemcutter repo. bundle package will cache the .gem files into your apps vendor/cache directory.
No need to run gem install first.