undefined method get_uptime for Facter::Util::Uptime:Module (NoMethodError) - ruby

I'm trying to setup a puppet node, but rubygems doesn't seem to behave.
If I run facter on the cli via it's own binary (/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter), it works fine, but if I run it through the binary installed by rubygems (/usr/bin/facter), it throws:
/usr/lib/ruby/1.8/facter/uptime.rb:11: undefined method `get_uptime' for Facter::Util::Uptime:Module (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:73:in `load'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:73:in `load_file'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:38:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:33:in `each'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:33:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:30:in `each'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:30:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/collection.rb:90:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter.rb:95:in `to_hash'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter:137
from /usr/bin/facter:19:in `load'
from /usr/bin/facter:19
I've tried removing rubygems and reinstalling as well as reinstalling the gem, but nothing seems to work.
I'm assuming something is cached somewhere, because it throws the same error when I'm trying to run puppet.
Any ideas?

It looks like you may have installed facter outside of rubygems before installing it with rubygems.
You'll notice the final file in the stacktrace is /usr/lib/ruby/1.8/facter/uptime.rb instead of being a file in /usr/lib/ruby/gems/1.8/gems/facter-1.5.8.
You should check if the files in /usr/lib/ruby/1.8/facter are indeed just an older version of factor and if so, you should be able to delete them or move them to a differently named directory and it will fix your problems.

Related

Ruby on Windows: `ansi.rb` get_screen_size error: in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)

I'm trying to use fastlane on Windows, which is installed from Bundler -- which is installed by Ruby Gem. But while running, some internal error of Ruby seems blocked the execution.
First, I went to Ruby Installer and installed Ruby+Devkit 3.0.2-1 (x64); then, I installed the Bundler and Fastlane using gem command. Error below happened when I was trying to execute them -- which I believed was not related to Bundler nor Fastlane:
C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:168:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/forwardable.rb:238:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:236:in `size_from_readline'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:66:in `size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:76:in `width'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane_core/lib/fastlane_core/print_table.rb:95:in `transform_output'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:335:in `print_plugin_information'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:316:in `load_plugins'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/commands_generator.rb:39:in `start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/cli_tools_distributor.rb:122:in `take_off'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/bin/fastlane:23:in `<top (required)>'
from C:/Ruby30-x64/bin/fastlane:23:in `load'
from C:/Ruby30-x64/bin/fastlane:23:in `<main>'
I'm using Windows 10 home version 20H2.
Rebooting the computer doesn't solve the problem.
I tried googling the question, but it seems that problem hasn't be reported (or be answered). I don't know where I can report the bug either.
What can I do? Any help would be appreciated!
I had this same error when I tried running bundle exec fastlane in git bash.
I got it working by running it in powershell instead.

Receive syntax error when installing gem on Ruby

I'm trying to install a gem using Ruby. I keep getting a weird syntax error when I do. Using rvm, latest version, to install. The error message is:
/Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/psych.rb:370:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 30 (Psych::SyntaxError)
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/psych.rb:370:in `parse_stream'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/psych.rb:318:in `parse'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/psych.rb:245:in `load'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:333:in `load_file'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:198:in `initialize'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/george/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/george/.rvm/rubies/ruby-2.1.5/bin/gem:21:in `<main>'
I also get this error when trying to set rvm to use a different ruby version.
There's an error in your rubygems config file. If you're not using a custom config file, look for a file .gemrc in your home folder. It seems there's incorrect content on line 2.
Psych is a YAML parser, so look for something that is incorrect YAML.
It looks like there was an issue in the .gemrc file as well as some other files created in the root folder that were affecting RVM from installing Ruby correctly.
Re-storing the files to the previous state and removing the junk files with rm -rf got everything working.

Invalid spec cache file

I have ruby 2.0.0p247 [x64-mingw32] with Gem 2.2.2 installed on Windows 8. I have a persistent problem gem that is making it virtually unusable. Whenever I try to install a new gem, I invariably get:
ERROR: While executing gem ... Invalid spec cache file in C:/Users/...
In the past, I've been able to run gem update or gem update --system and that would clear up the problem for one, single gem install. Subsequent install would fail with the same error. Now even gem update fails with that error message.
I've tried deleting the users/.../.gem directory. When I do that, gem update recreates that directory and promptly fails with the same error message.
I re-installed ruby 1.9.8 with gems several times to try to cure the problem, then upgraded to ruby 2.0.0. Throughout all re-installs and upgrades, the problem persisted.
I'm at my wits end here. Can anyone help me resolve this issue?
Here's the backtrace on the edit"
L:\xampp\htdocs\frameworks\yii2\framework>gem update --backtrace
Updating installed gems
ERROR: While executing gem ... (Gem::Exception)
Invalid spec cache file in C:/Users/Larry/.gem/specs/rubygems.org%443/specs.4.8
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:187:in `rescue in load_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:179:in `load_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:266:in `tuples_for'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:228:in `block in available_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each_source'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:222:in `available_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:102:in `search_for_dependency'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:113:in `fetch_remote_gems'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:135:in `highest_remote_version'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:264:in `block in which_to_update'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `each'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `which_to_update'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:96:in `execute'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command.rb:305:in `invoke_with_build_args'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:167:in `process_args'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:137:in `run'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:54:in `run'
C:/Ruby200-x64/bin/gem:21:in `<main>'
I had the same problem, but was able to fix it this way:
Delete the folder in users/%user%/.gem/ and rerun the command gem sources --update
Hope this helps.

Capistrano Using Old Ruby Version

I'm trying to get Capistrano to work on my MacBook (OSX Mountain Lion) but am having a lot of difficulties. It started with it throwing an error:
cillosis:myapp macbook$ cap deploy
/Library/Ruby/Gems/1.8/gems/sshkit-1.2.0/lib/sshkit.rb:32: undefined method `require_relative' for main:Object (NoMethodError)
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/capistrano-3.0.1/lib/capistrano/all.rb:2
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/capistrano-3.0.1/bin/cap:2
from /usr/bin/cap:19:in `load'
from /usr/bin/cap:19
It seemed I had Ruby 1.8 installed and it doesn't work correctly with Capistrano (found this Googling around).
So I installed Ruby 2.0 using rvm. RVM starting throwing a bunch of errors so I got rid of it using rvm implode and found that the 2.0 version was still on my computer. I checked my $PATH and the locations it pointed at contained the Ruby 1.8. So I renamed that to *ruby_old* and copied the new ruby to that folder (/usr/bin). Then when I did a ruby -v it came back as version 2.0. So I thought, great, now we can finally run Capistrano.
Just to be sure, I did a gem update which came back as having updated the sshkit gem which was throwing the error before. So I go to deploy, and get the same exact error as I started with.
I know the deploy.rb script is correct because I use it all the time on another Mac.
TL;DR; After some fumbling, when I type ruby -v it comes back as using version 2.0 but when I do a cap deploy with Capistrano, it tries to use version 1.8 of ruby. How do I fix this?
The dumb, but simple way out would be to completely remove RVM and both ruby versions, then install again from scratch. I would recommend 1.9.x over 2.0 due to some gems not being up to speed yet, but that's up to you.
Another option would be to specify the ruby version in your gemfile (as heroku does it), then do a "bundle exec cap deploy". Again, no guarantees - but it might force capistrano to behave the way you want until you find a proper solution.

RSPEC Setup Help - Mountain Lion Ruby 1.9.3

Setting up my first developing environment, so bear with me. Running Mountain Lion, Ruby 1.9.3, Gems 1.8.25 and RVM 1.19.1.
Trying to get RSPEC up and running, but I keep getting an error. I think it has to do with my PATH, as most questions about this refer to the fact that their shell (Bash?) is looking in the wrong place.
Using this wonderful tutorial: http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/
I've tried running the simplest rspec files and get an error, so I tried just typing "spec" (no quotes) in the command-line. That gives me the error "-bash: spec: command not found" (no quotes).
Looked around stackoverflow and saw that the command was updated to "rspec" instead of "spec"? So when I type "rspec" (no quotes) into the command line I get this nonsense:
Evans-MacBook-Pro:~ Evan$ rspec
/Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file -- /Users/Evan/spec (LoadError)
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /Users/Evan/.rvm/gems/ruby-1.9.3-p392/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
Regarding previous answers I found to this question: my attempts to alter the .bashrc just left me confused about what the heck I was doing, and I don't think I got the syntax right (also it didn't work).
Any thoughts? Much appreciated!
Evan
Rspec assumes your specs in a spec/ directory which cannot be found. Try running
rspec spec_tutorial
Btw. this tutorial is pretty outdated. Try using rspec.info instead for example.

Resources