toy/doc undefined method 'available?' - ruby

I'm attempting to build local Ruby documentation as suggested here:
https://github.com/toy/doc
However when I use the default Rakefile I get the following:
[Documentation]$ rake build
configuring and updating: 100.0%
rake aborted!
undefined method `available?' for Gem:Module
/Users/snowcrash/.rvm/gems/ruby-2.0.0-p195/gems/sdoc-0.2.20/lib/sdoc/json_backend.rb:9:in `<top (required)>'
Any suggestions?

I don't know much about ruby (and even less about the gem ecosystem built up around it), but I believe a possible workaround for this issue is to find what gems the project requires and manually install them. In the case of this particular project, it looks like you need the gem "fspath".
At the project root, type
gem install fspath
and try re-running rake.
I honestly don't know the actual root cause of the issue, other than that presumably, your version of the 'gem' program is probably > v2, while some other program (rake?) expects it to be older and still support the "available?" method.
If installing "fspath" doesn't fix the issue, you could try downgrading your version of gem by doing
gem install -v [some version of gem older than v2]
Check gem install --help for more info on this.

This is just for future visitor who has the same issue.
As ekremkaraca said, you can just solve this by downgrading rubygems.
rvm install --force rubygems 1.4.2

Related

Issues installing/updating Bundler

I have tried this a number of different ways. First I tried with RVM and it was just error after error and missing dependencies. Then I tried Rbenv and it was very much the same.
Now, I have a combo of chruby and ruby-install to handle my versions of Ruby, but I can't update Bundler.
It says that I am currently on 1.17.2, but I need 1.17.3.
How do I upgrade this? I have searched everywhere, but all the solutions seems to be for RVM.
When I try to update Bundler this is the error that I get:
$ gem update bundler
ERROR: Loading command: update (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I don't know what is causing this or how to get around it. Any help would be appreciated as I can't seem to find anything describing what is happening.
So, it turns out that I had multiple versions of Bundler installed on my machine and, somehow, two of them were simultaneously set to the default version.
Manually finding the installed versions, deleting them and then reinstalling the desired version seemed to fix the issue.
The key is using a Ruby manager (RVM, rbenv, etc.) and ensuring that any installation of a Ruby version and/or gems are done at either a system level or inside of a project as required.

How to fix "uninitialized constant Gem::GEM_PRELUDE_SUCKAGE" in RubyGems tasks

My RubyGems isn't working, throwing an error which goes as follows, triggering (nearly) on any Gem task:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:1081:in `<top (required)>': uninitialized constant Gem::GEM_PRELUDE_SUCKAGE (NameError)
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
I'm new to Ruby / RubyGems / installing Ruby and all I know is that an uninitialized constant is essentially a undefined variable. It could also be possible that it's something with Ruby itself, although the ->Gem:GEM<-_PRELUDE_SUCKAGE points me to RubyGems.
In a nutshell, I installed a bunch of Ruby things (think RVM, rbenv, etc.) to develop Ruby on Rails, as I thought it would be a good way to learn Ruby.
Well, after going through a long and tedious process to upgrade Ruby to 2.6.3, then downgrade to 2.5.5 and then 2.4.0, then back up to 2.5.5 and solving downgrade issues, RubyGems throws the error. I settled on 2.5.5 because 2.6.3 caused errors and 2.4.0 was too early of a version.
It's causing all sorts of errors, like HAML not compiling and Rails not making a controller. I really don't know what's happening.
If I run gem install [gem name], it throws the error. Running rails generate controller [name] index (for those not familiar to Rails this creates, well, a controller) it throws the error. Doing anything really with the gem command causes the error, except for gem server.
If I upgrade back up to the latest Ruby version, I fear that my gem command will go all wonky again and I'll have to go through another day of troubleshooting versions. How do I fix this, or at least get rid of the message so I can create things again?
I had this happen to me just today. It seems, somehow, my ruby version had been corrupted. When I ran rvm list version 2.5.1 was listed as 'broken'. I had to uninstall 2.5.1 fully (using sudo even in my case) to get to a clean slate.
Then, when attempting to reinstall, rvm was giving me all kinds of grief after a new gpg key which I initialy couldn't get to install properly (hint).
After a clean wipe of ruby 2.5.1, updating rvm to latest version and reinstalling, I got this error: Error running 'env GEM_HOME=/ruby-2.5.1#global GEM_PATH= /Users/user/.rvm/rubies/ruby-2.5.1/bin/ruby -d /Users/user/.rvm/src/rubygems-3.0.8/setup.rb --no-document',.
It appears that an update to MacOSX deprecated a version of OpenSSL which causes some issues. I ended up following this thread and ran rvm gemset create global --default and then bundle install to get passed the Gem errors.
Honestly, rails is supposed to be easier than this. I wish docker was easier to reason about sometimes. These are the kinds of issues docker supposedly promises to fix eh?

enforcing a ruby gem version

I am completely new to ruby, don't know the 1st thing about rvm, gemset etc. Just forced to use a CLI tool (kensa by heroku) written in ruby and facing an issue.
The kensa tool seems to use a gem named rest-client. When I run it it throws an error:
/Users/shaharsol/.rvm/gems/ruby-2.4.2/gems/rest-client-1.8.0/lib/restclient/request.rb:163:in `fetch': key not found: :ciphers (KeyError)
Some searches suggest that v1.8 of rest-client is too old so I installed v2.0.2. Now when I do a gem list I get:
rest-client (2.0.2, 1.8.0)
When I run kensa again it still used to old version. So I went and modified it kensa.gemspec file (which is referred to from Gemfile) and to my best understanding told it to use the newer version:
s.add_runtime_dependency(%q<rest-client>, "~> 2.0")
Yet, when I run kensa again, it still uses the old rest-client 1.8.0!
What am I missing? What am I doing wrong? Or what else is required for the kensa to run with the new rest-client 2.0.2 ???
PS - If my problem doesn't relate at all to changing 1.8.0 => 2.0.2 please tell me what else to do. I really don't care which rest-client version kensa uses, I just need it to run!
To remove older version of the gem, you have two options:
# remove all versions of the gem
gem cleanup rest-client
After this, you can do 'bundle install' and only install the version you want.
# choose which one you want to remove
gem uninstall rest-client --version 1.8.0
After this, you will only have 2.0.2 version.
Hope this solves your problem.

Can I control the version of rubygems that IntelliJ uses?

I'm trying to start a rails application in IntelliJ with the Ruby plugin.
I've imported the application and set up the run configuration as best I can. When I try to run it I get the error:
NoMethodError: undefined method `version_requirements' for #<Gem::Dependency:0x7de21f45>
When looking for an answer I found this page saying that I should do this:
$ gem install rubygems-update -v='1.4.2'
$ gem uninstall rubygems-update -v='1.5.0'
$ update_rubygems
Since it's IntelliJ's ruby plugin that is managing the gems, I assume that I have to change the version of rubygems-update that the plugin is using.
Is this the right approach to take? And if so, can anyone tell me how to go about it?
I tried listing the gems but that gem is not shows so I must not be listing the gems in the right place, but I don't know where to look.
Many thanks :)
IntelliJ IDEA cannot handle it, you will need to install the appropriate rubygems version from the command line.
Note that your current rubygems-update version may be different, verify it with gem list and use the reported version when uninstalling.

Rake failing to start

I'm having trouble understanding the following error with Ruby's Rake.
C:\>gem install rake
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Installing RDoc documentation for rake-0.8.7...
C:\>rake
C:/Ruby192/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path': can't find executable r
ake for rake-0.8.7 (Gem::Exception)
from C:/Ruby192/bin/rake:19:in `<main>'
Running Ruby 1.9.2 for Windows.
Edit: Installing from source yields:
C:\Documents and Settings\XPherior\Desktop\rake-0.8.7\rake-0.8.7>ruby install.rb
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load --
ftools (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from install.rb:3:in `<main>'
The second error, where you have installed into C:\Documenets And Settings\ is occurring because you cannot install ruby into a folder with a space in the path. It should be installed into c:\Ruby\ c:\Ruby#.#.#\ if you want the version # in the path, or something along those lines.
for the first error: there is a bug in the rubyinstaller.org version of ruby 1.9.2, which is causing this by running "gem install rake".
you can read about the error you're getting, here: http://redmine.ruby-lang.org/issues/show/3677
there are a couple of ways to fix this error:
re-install ruby v1.9.2 and don't run "gem install rake". rake v0.8.7 is built into the ruby v1.9.2 installation, so you don't need to re-install it.
if you do want to manually install it, you can delete the ruby.gempspec file from your ruby installation. this file is located at (rubyinstalldir)\lib\ruby\gems\1.9.1\specifications
either of these options will fix the problem for you.
i'm not sure which is "better" off-hand... it may be necessary to delete the gemspec file and reinstall rake, to support updates and new versions in the future. i'm not sure, though. we'll find out once rake is updated and we need to install a new version. or, perhaps, the issue will be fixed in the ruby installation by then, and we'll just need to update our ruby install.
I've run into your both errors.
For the first one. Try the solution post at here http://betterlogic.com/roger/2010/11/ruby-1-9-2-rake-woe/.
And for the second error, it's causes by a library update by the ruby 1.9. From the Programming Ruby 1.9, "ftools have been removed (and replaced by fileutils)." I'm not pretty sure but at least that's an explanation.

Resources