I am trying to search TCPSocket ruby class documentation with ri but it shows nothing. Most of the gems are shown. I am using rvm, and require 'socket' works perfectly. How to fix this?
Try using:
gem rdoc --all
The documentation says:
--all Generate RDoc/RI documentation for all
installed gems
You can find these things out by typing:
gem help
or
gem help rdoc
at the command line.
You might want to throw on --overwrite to overwrite existing documentation.
Old versions of Ruby, around 1.8, didn't always have the core and/or std-lib documentation generated. There's a gem you can install that patches that, but I don't remember what it was right now.
Related
I am trying to install chiliproject on a server, following the -well done- documentation I am hitting this error
Could not find gem 'rubytree (~> 0.5.2) ruby' in any of the gem sources listed in your Gemfile.
I did a gem install rubytree
I get this message
========================================================================
Thank you for installing rubytree.
WARNING: SIGNIFICANT API CHANGE in 0.8.0 !
------------------------------------------
Please note that as of 0.8.0 the CamelCase method names are DEPRECATED.
The new method names follow the ruby_convention (separated by '_').
The old CamelCase methods still work (a warning will be displayed),
but may go away in the future.
Details of the API changes are documented in the API-CHANGES file.
========================================================================
Successfully installed rubytree-0.8.1
1 gem installed
Installing ri documentation for rubytree-0.8.1...
file 'COPYING,API-CHANGES' not found
Installing RDoc documentation for rubytree-0.8.1...
file 'COPYING,API-CHANGES' not found
That is saying the installation was succesful. So why do I get the error ?
If the error is from the API change how can I request version 0.5.2 of the rubytree gem ?
When I do a gem list --local | grep 'rubytree'
I have this output rubytree (0.8.1)
So why is the system saying could not find gem 'rubytree' ?
thank you for any help,
Depending on what version of rails you are using (and it sounds like you are using a relatively newer one, if it's prompting you for your Gemfile), then you need to use Bundler to manage your gems.
Try editing your Gemfile, adding a new line that reads:
gem "rubytree", "< 0.6"
Then open up a console, and type this command
bundle install
This should fix your problems, but if you still get errors when running a command, then try typing bundle exec prior to the command (i.e. rails server becomes bundle exec rails server).
Currently, we require rubytree exactly in version 0.5.2 or 0.5.3, as specified in our Gemfile, the 0.8.1. version you installed by hand will not suffice that requirement, which is exactly what the error message states.
What seems a bit odd is the literal ruby in the error message. Could you please make sure that you have the exact unchanged Gemfile from the source on your system? Also, could you please remove any user-installed plugins and try again? Also, which ruby (type and version) on which operating system are you using?
-- UPDATE --
Ok its fixed. This is what I did. remove all ruby and rubygems completely. then install ruby1.9.1-full and rubygems1.9.1 then install the twitter gem.
Hi guys,
I am having trouble working with the Twitter gem. I am using ruby 1.8.7
After installing when I try to run a simple script I get this error
ruby twitter.rb
./twitter.rb:5: uninitialized constant Twitter (NameError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from twitter.rb:2
I running this on a Ubuntu box. I checked with gem -list and I see the Twitter (1.1.0) is listed there.
this is the code I am trying to run
require "rubygems"
require 'twitter'
puts Twitter.user_timeline("test").first.text
Any ideas ?
I believe it only works with Ruby 1.9 If you want to use twitter gem try version 0.9 with Ruby 1.8.x
This works for me:
ruby-1.9.2-p0 > require 'twitter'
=> true
ruby-1.9.2-p0 > puts Twitter.user_timeline("test").first.text
TExES Pedagogy and Professional Responsibilities EC-12 Teacher Certification Test Prep Study Guid… - by Sharon A Wynne http://amzn.to/f3kF74
=> nil
which version of ruby are you using?
gouravtiwari21's comment seems to fix the problem, but it's wrong to suggest that the twitter gem requires 0.9.0 if you want to run it using Ruby 1.8.x.
You can check out the version compatibility here:
http://travis-ci.org/#!/jnunemaker/twitter
It shows the twitter gem working with Ruby installs as low as 1.8.7.
For me, it was an issue with having the correct dependent gems, as well as the correct versions.
Here's how I got it working:
I ran:
sudo gem list
And compared the versions of specific gems with what I found here:
https://github.com/jnunemaker/twitter/blob/master/HISTORY.md (I simply searched for the word 'dependency' to see which versions twitter cared about.
I also found this diff:
https://github.com/jnunemaker/twitter/commit/ac8114c1f6ba2da20c2267d3133252c2ffc6b6a3
And I compared the gems listed there with what I had installed, and I just made sure my system lined up with what I was seeing in the version notes. Oftentimes what happened is that I had multiple versions of a gem, and for some reason, the lower version was taking precedence.
I'm not sure why I still have to add
gem 'twitter', '1.7.1'
to my Gemfile, but alas, that's the last step required in order to get this stuff working.
Don't forget to restart your server, and you should be good!
I'm new to Ruby. I have a .bundle file. I put it in the source folder and did
require('my.bundle')
But when I call the methods in the bundle, the definition is not found. Do I have to install them or include them in some other way to access them?
I am on Ruby version 1.8.7 (latest version on Mac).
I highly recommend using RVM to manage your Ruby installation, including your gems, so if you don't already have that, get it and follow the instructions for installing it. Make sure you do the part about modifying your bash startup script or you'll see weird behavior, like the wrong Ruby being called. Also, use the steps in "RVM and RubyGems" to install your gems or you can run into weird behavior with gems being installed under the wrong or an unexpected Ruby.
Second, use the gem command to install gems:
gem install gem_to_install
replacing "gem_to_install" with the name of the gem you want, and it will be installed into the appropriate gem folder for your Ruby.
If you are on Ruby 1.92, and trying to require a gem to use as a module in your code, use:
require 'gemname'
if it is installed via the gem command. And, if it is a module you wrote or have in your program's directory or below it, use:
require_relative 'path/to/gem/gemname'
If you are on a Ruby < 1.9 you'll also need to add require 'rubygems' above your other require lines, then use require './path/to/gem/gemname'.
Thanks, but my .bundle is not in gems. How do I install/require a .bundle file I already have?
If you wrote it look into rubygems/gemcutter or bundler for info on bundling and managing gems.
You can install a gem without using the app by going into the directory containing the gem and running setup.rb. See http://i.loveruby.net/en/projects/setup/doc/usage.html for a decent writeup or the official docs at: http://docs.rubygems.org/read/chapter/3
I've recently installed Ruby 1.9.1 on Windows 7, and apparently it doesn't come with the standard ri documentation. So when I do 'ri Array', I get:
C:\>ri Array
Nothing known about Array
Is there a way I can install this documentation so that the above works?
In case people on other platforms need to install their ri docs (like I did). This article gives the why and the how:
http://jstorimer.com/ri.html
The command is:
gem rdoc --all --ri --no-rdoc
If you are using rvm you should rvm docs generate (or just rvm docs generate-ri)
See this info (2011August) about rvm and ri
None of the proposed solutions worked for me. In the end the solution I found was super simple, so I'll leave it here. (I'm running ruby 2.2.4 on win7 x64 in case that's relevant)
(captain obvious alert: ruby must be installed and in your PATH)
-open cmd
-$ gem install rdoc-data
-$ rdoc-data --install
And you're set! test that it worked by running:
-$ ri Array It should give you all the lovely documentation for the class!
Hope this helps!
ps. I just noticed that this is the solution that Luis Lavena proposed in a comment, but his comment wasn't clear to me so I had continued searching. Basically this is the same solution but explained more clearly so that that doesn't happen to anyone else :)
Cheers!
Things are still largely the same with Ruby Installer 2.4.1.2 (year 2017). If I run ri Array, it shows Array < Object and nothing else. If I run ri "Array#each", I get the familiar "Nothing known..." message. In short, the ri-format documentation on Ruby core and standard libraries are missing.
Here's how I got my copy of core/stdlib ri-documentation. Of course, Ruby must be installed prior to this.
Get ruby's source code that most closely matches my version from their Github releases page.
Extract the .zip or .tar.gz archive to some folder
Open cmd.exe/Powershell, cd to that folder and run rdoc --all --ri
This command parses .c files, .rb files, and a few other file types in the current directory recursively and generates ri-documentation to ~/.rdoc directory.
Took about 5 minutes on my laptop with i7-3520M processor to complete, with no errors.
Delete the archive and the directory containing the source code because we don't need them anymore.
Now if you try running ri Array or ri "Array#each" you'll get the documentation in all its glory.
tl;dr
Run rdoc --all --ri on directory containing source code for same ruby version as your installed version.
Appendix Z: Comments on other answers
The rvm docs generate-ri could work, but you have to use Cygwin or Ubuntu on Windows (if on Windows 10) to use rvm.
gem rdoc --all --ri --no-rdoc installs ri-documentation for all your gems. It doesn't install the core/stdlib documentations.
gem install rdoc-data followed by rdoc-data --install only works for Ruby versions up to 2.3.0.
Seems you have installer Ruby 1.9.1 distributed by the RubyInstaller project.
You can use the Windows Help Files (CHM) that came with the installer instead of the ri documentation.
The problem of the RI documentation is that some versions of RDoc have problems generating it and also generated more than 10 thousands files which slowed down the installers considerably.
RVM does not automatically generate and install each Ruby's ri / rdoc documentation. You can generate using the following command:
rvm docs generate
All the Ruby Docs are at http://www.ruby-doc.org
So the array documentation is at:
http://ruby-doc.org/core/classes/Array.html
Never tried it on windows but because its saying Nothing Known about X its not that its not installed just not got anything there.
Try installing a gem as you can then ri GEM_CLASS as that should provide defentions, should let us see if its missing documentation or if ri's not looking in the right place
You might run into this issue under Docker. The official docker images come with no documentation, and apparently disable installing gem documentation.
If image's and system ruby versions match (specifically, RbConfig::CONFIG["ruby_version"], which is e.g. 2.6.0 for ruby-2.6.1), you can:
# apk add ruby-doc
# cp -r /usr/share/ri /usr/local/share/ri
I've never seen the point of installing the ri and rdoc for gems and my .gemrc file has --no-ri and --no-rdoc set. Since every gem includes ri and rdoc info, I just wondered if I'm missing something? Is there any advantage to installing the ri and rdoc for a gem?
Thanks
Chris
Summary
If you don't install the ri and rdoc, you don't lose anything of great value. I thought perhaps it got used in some of the IDEs (I'm an Emacs user) but that doesn't seem to be the case.
The point of installing ri documentation is simply that you can use the "ri" command to access method-by-method documentation. For an example, try: "ri String#reverse". Exit by pressing "q".
To try out RDoc documentation, run "gem server" and then connect to localhost:8808 in your browser. I find it useful - you can even click on a method name to see the source code. Of course, you can just go into your gems folder and open the HTML files in the doc folder.
An alternate way to access RDoc is the gemdoc command. See http://www.stephencelis.com/2008/06/12/bashfully-yours-gem-shortcuts.html. That's quite handy, IMHO.
Anyway, you can be lazy and wait until you need the RDoc documentation, and then generate it with "gem rdoc ".
Personally, I'm installing my gems without rdoc and ri, too, because normally you can find all the documentation you need on the internet as well (i.e. www.rdoc.info), so there's no need for investing hard disk space and time the generation takes
Install it if you want locally available documentation for the gem.
This article gives a great why and how of using ri:
http://jstorimer.com/ri.html
Best point on that list is #1: ri understands Ruby. For instance:
$ ri ActiveRecord::Base#save
(from gem activerecord-3.2.8)
Implementation from ActiveRecord::Persistence
[...]
(from gem activerecord-3.2.8)
Implementation from ActiveRecord::Validations
[...]
Notice the method is found even if not directly on ActiveRecord::Base itself.