I'm a newbie to Ruby on Rails. I had a quick question about installing gems.
I'm using a windows 7 64 bit machine with Ruby 1.9.2 and Rails 3.0 and I'm trying to install the gravatar_image_tag gem.
gem install gravatar_image_tag
After I run that it says its succcessful. But when I try to do this:
gravatar_image_tag -v
It says that 'gravatar_image_tag' is not recognized as an internal or external command, operable program or batch file'
When i looked into my ruby192/bin file there are batch files for rails, annotate etc etc that work fine but there's not batch file for gravatar_image_tag.
I was wondering where I'm going wrong with this.
Thanks in advance.
Not all gems are executable from the command line. The best way to see if a gem is installed (as well as its version) is to run:
gem list
If you want to use a gem inside your rails 3 project, you should add it to your Gemfile (in the root of your project). Something like this
gem "gravatar_image_tag"
then run bundle install.
The gravatar_image_tag should placed somewhere in your view, to generate the correct html.
More information can be found on their github page.
[EDIT] Maybe my answer was not too the point. To check if the gem was correctly installed, you either type
gem list gravatar_image_tag
or
bundle show gravatar_image_tag
if you installed the gem using bundler.
Not all gems install a batch-file, and according to the documentation this doesn't either.
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 installing Ruby on Windows 10.
I already installed Ruby 2.3
When I tried to install Rails 4.2.6 I had problems with nokogiri.
Thanks to this questions and answers I was able to solve by installing nokogiri version 1.6.6.4 then rails then version 1.6.8.rc3 like this:
gem install nokogiri -v '1.6.6.4'
gem install rails
gem install nokogiri -v '1.6.8.rc3'
But after that, I'm supposed to include this:
gem 'nokogiri', '>=1.6.8.rc3'
in gemfile.
When asked, the guys says:
Hey, guys, just add gem 'nokogiri', '>=1.6.8.rc3 in your Rails
application Gemfile (outside of the development, test, production
group) and run bundle update nokogiri.
But I'm not sure where is the Rails application gemfile or which file should I edit.
From this previous question I can see how the file content is but there isnt much explanation about where do I find it.
I'm about to take a tutorial in Ruby o Rails, so I'm below noob, and the first page tutorial is about installing Ruby and Rails, it's supposed to install easy except for the nokigiri problem (only a Windows problem it seems).
The Gemfile is typically located in the root of your project and is called just that Gemfile.
Don't change the Gemfile.lock file it is written automatically.
You can find a file with name 'Gemfile' at the root of your rails application.
"The Rails application gemfile" is the file called Gemfile, in the root of your project.
You have already pasted the contents of this file in your previous question.
I have updated all of my gems, including to Rails 3.2.8, prior to a new deployment. However, my application is now broken because something is trying to install gem "termios" version 0.9.4.
Apparently, 0.9.4 does not work on any computer or server I own. There are some newer versions, 0.9.6 specifically, but they are not posted in wherever bundler looks for gems.
There are some version on Github, but they have been mysteriously renamed "ruby-termios". Well, some gem in my Gemfile is not looking for ruby-termios. It's looking for termios. Failure.
How can I find out which gem is trying to install this so I can see if it can be whacked?
Check your Gemfile.lock - it has all the gems and their dependencies listed in it. As long as you've been able to install these gems in the past, you'll be able to tell where that dependency is coming from.
The gem command will dump out the tree of dependencies for you.
$ gem dependency
Or if you want to check just a specific gem.
$ gem dependency foo
I am completely new to Ruby and need to use Ruby on Rails 2.3.5 on Windows. I have downloaded the zip from GitHub here: https://github.com/rails/rails/tree/v2.3.5
There was no gem file so I tried rake in the extracted directory. It took ages and seemed to have a lot of errors, but it did eventually complete.
There was no gem file created (is this even what rake is supposed to do?). And rails is not installed (typing rails at the command prompt doesnt work).
Any ideas what I am doing wrong?
EDIT: I cannot use gem install rails -v "2.3.5" as I am behind a firewall. I think I need to install it from local files.
You first need to download and install Ruby 1.8.7.
You can then install Rails via gem install rails -v=2.3.5
I would recommended you download the gems of Rails 2.3.5 from: http://rubygems.org/gems/rails/versions/2.3.5
You also need other dependencies, such as:
actionmailer = 2.3.5
actionpack = 2.3.5
activerecord = 2.3.5
activeresource = 2.3.5
activesupport = 2.3.5
rake >= 0.8.3
Since you do not have an direct internet connection, you need to download them by hand.
After you download them, use "gem install xxx.gem" to install
install ruby, include gems support.
at the command line
gem install rails
Do not install instant rails, as it is outdated and unmaintained. Use RailsInstaller http://railsinstaller.org/
You normally install Rails by only using gem, you only install "by hand" if it is not hosted anywhere.
Do the following steps (I suppose that ruby is installed and the gem command is working):
gem install rails -v 2.3.5
This should include all needed gems as well, and will install the rails command in your shell. However, to use it in Windows is a little bit difficult, because the installation of sqlite3 is not so easy.
If you could access outside world through a corporate proxy, you could use it's address in gem command, like this: gem install rails -v 2.3.5 -p http://corporate_proxy
Install InstantRails: http://broadcast.oreilly.com/2008/12/installing-instant-rails-on-wi.html
I'm very new to Rails (and Ruby), and am having trouble installing and using gems. I'm trying to use ruby-tmdb (https://github.com/aarongough/ruby-tmdb) and there's very little documentation.
"sudo gem install ruby-tmdb" runs just fine and I can see the gem installed when I run "gem list --local"
But, when I try and run the app, I get the error "no such file to load -- ruby-tmdb".
I'm on Mac OS X Snow Leopard. Ruby 1.8.7. Rails 3.0.3. Gem 1.3.7.
Is the gem listed in your Gemfile? In Rails 3, all gem dependencies should be listed in the Gemfile, so that it is properly loaded when the app runs.
You should have something like the following line:
gem 'ruby-tmdb'
Then, run bundle install to ensure that all gem dependencies are installed, and to have Bundler save the lock file that will ensure that all copies of this application run with the same gem versions. From this point on, you will no longer have to write the require line yourself; Rails will load in all necessary gems as the environment loads.
You might get the same error even after this, but it's always worth going through the standard process to help narrow things down :)
$ sudo which gem
$ which gem
$ sudo ruby -v
$ ruby -v
Sometimes users have different gems and rubys compared to root.
A common problem is that a gem installed for ruby 1.8 by root isn't visible for the users ruby 1.9
gems for ruby 1.8 and gems for 1.9 are NOT compatible.
This probably isn't the issue but is something that may be worth considering.