Ruby yob pdf reader, wrong argument quantity - ruby

I'm trying to install the yob pdf reader: https://github.com/yob/pdf-reader#readme
My script has the following code:
reader = PDF::Reader.new("1.pdf")
when I run that script I get the following error:
`initialize': wrong number of arguments (1 for 0) (ArgumentError)
Which doesn't make any sense because the directions say this should be done this way.
How do I solve this?
p.s.
gem list command produces:
*** LOCAL GEMS ***
Ascii85 (1.0.1)
bundler (1.0.18)
columnize (0.3.4)
linecache (0.46)
nokogiri (1.5.0)
pdf-reader (0.10.0)
rbx-require-relative (0.0.5)
rdoc (3.9.4, 2.5.11)
rdoc-data (2.5.3)
ruby-debug (0.10.4)
ruby-debug-base (0.10.4)
rudebug (0.3.2)
syntax (1.0.0)
gem -v produces: 1.3.7

You most likely have a gem version conflict. You can specify the version of the gem that you want to require, in case you have multiple versions installed:
require 'rubygems'
gem 'pdf-reader', "~> 0.10.0"
require 'pdf-reader'
Update
I would slap myself if I could. There's nothing wrong with your setup. The instructions to use PDF::Reader.new "my_file.pdf" are for the git version.
Check the examples directory for the version 0.10.0 to get examples of how to use the library.

Related

Ruby can't find installed gems windows 10

When running a script containing the following
require 'rubygems'
require 'zip'
I am getting
`require': cannot load such file -- zip
First I have tried to install like this 'rubyzip'
gem install rubyzip
When looking at the gem env:
>gem env
RubyGems Environment:
RUBYGEMS VERSION: 2.4.8
RUBY VERSION: 2.2.3 (2016-01-26 patchlevel 0) [java]
INSTALLATION DIRECTORY: C:/jruby-9.0.5.0/lib/ruby/gems/shared
RUBY EXECUTABLE: C:/jruby-9.0.5.0/bin/jruby.exe
EXECUTABLE DIRECTORY: C:/jruby-9.0.5.0/bin
SPEC CACHE DIRECTORY: C:/Users/lucio/.gem/specs
SYSTEM CONFIGURATION DIRECTORY: C:/jruby-9.0.5.0/etc
RUBYGEMS PLATFORMS:
- ruby
- universal-java-1.8
GEM PATHS:
- C:/jruby-9.0.5.0/lib/ruby/gems/shared
- C:/Users/lucio/.gem/jruby/2.2.0
in the irb seems like the require works
irb(main):001:0> require 'zip'
=> true
I also trying to install with bundler after installing
>bundle show
Gems included by the bundle:
* bundler (1.12.4)
* rubyzip (1.2.0)
but when running my script I get
>bundler exec ruby zip.rb
Could not find rubyzip-1.2.0 in any of the sources
Run `bundle install` to install missing gems.
I can also see it in the gem list
>gem list -l
*** LOCAL GEMS ***
bundler (1.12.4)
jar-dependencies (0.2.3)
jruby-openssl (0.9.15 java)
jruby-win32ole (0.8.5)
json (1.8.0 java)
minitest (5.4.1)
power_assert (0.2.3)
psych (2.0.15 java)
racc (1.4.13 java)
rake (10.1.0)
rdoc (4.1.2)
rubygems-update (2.6.4)
rubyzip (1.2.0)
Can anybody help ?
Found the problem.
I had Jruby installed along with Ruby, so when installing the gem it will automatically install under the Jruby directory and later won't be found by Ruby removing the Jruby from PATH end variable solved the problem

Bundler could not find compatible versions for gem "rubyzip"

I tried to add docx-html gem to my project and here's what I get while bundle install:
Bundler could not find compatible versions for gem "rubyzip": In
Gemfile:
zip-zip (>= 0) ruby depends on
rubyzip (>= 1.0.0) ruby
docx-html (>= 0) ruby depends on
docx (~> 0.1.0) ruby depends on
rubyzip (0.9.1)
Part of my Gemfile:
gem 'rubyzip'
gem 'zip-zip'
gem 'docx_replace'
I added the line gem 'zip-zip' by an advice from another StackOverflow question. If I exclude it, instead of bundle install error I get the following error while trying to start the server:
`require': cannot load such file -- zip
How do I get rid of these errors while keeping gem docx_replace?
I haven't yet figured out why, but for some reason changing Gemfile code to this worked:
gem 'zip'
gem 'docx_replace'

Can't install bundle - endless error message

This is what I'm using: Windows 8. Cygwin32. Rvm version 1.25.27. Ruby version 2.1.2p95. Gem version 2.3.0. Drush version 5.9.
I'm totally new to all this so it's very possible that the explanation is something really simple.
I tried to use "drush omega-guard" from my drupal theme folder but got an error saying I had to install Bundler version 1.2 or newer. This is all fine since I hadn't installed bundle. But when I try to use the command "bundle install" I get this:
$ bundle install
-bash: bundle: kommandot finns inte
(Kommandot finns inte = Command not found.)
When I try using "gem bundler install" I get this:
$ gem bundler install
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command bundler
I also tried "gem bundle install":
$ gem bundle install
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command bundle
So I used "which bundle" and then used cd to get to that folder.
$ which bundle
/home/I/.rvm/gems/ruby-2.1.2/bin/bundle
I tried the same commands again, but from the other folder, and ended up with this:
I#I ~/.rvm/gems/ruby-2.1.2/bin
$ gem install bundler
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
I#I ~/.rvm/gems/ruby-2.1.2/bin
$ gem install bundle
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
I#I ~/.rvm/gems/ruby-2.1.2/bin
$ bundle install
/home/I/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'bundler' (>= 0) among 13 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/home/I/.rvm/gems/ruby-2.1.2:/home/I/.rvm/gems/ruby-2.1.2#global', execute `gem env` for more information
from /home/I/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:322:in `to_spec'
from /home/I/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /home/I/.rvm/gems/ruby-2.1.2/bin/bundle:22:in `<main>'
When I use command "gem list" bundle isn't listed:
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.5, 1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (5.3.5, 4.7.5)
psych (2.0.5)
rake (10.3.2, 10.1.0)
rdoc (4.1.1, 4.1.0)
test-unit (2.5.5, 2.1.2.0)
What am I missing or doing wrong? I have been following this tutorial and everything has worked fine up until this point: https://www.youtube.com/watch?v=XF_LaSfua8Y&index=10&list=PLLnpHn493BHH5nnK2dKE_42l1oXA6Tq6H
EDIT: Since I asked this question I tried reinstalling ruby 2.1.2. The installation stuck on "#importing gemset" and after about 36 hours my computer was turned of due to a blackout. I therefore don't know if the reinstallation was completed or not. After that I also changed my gem version to 2.1.2 to match the ruby version. Theese things seemed to help and afterwards I could run both "gem install bundler" and "bundle install". My gemlist now looks like this:
$ gem list
*** LOCAL GEMS ***
addressable (2.3.6)
bigdecimal (1.2.5, 1.2.4)
breakpoint (2.0.7)
bundle (0.0.1)
bundler (1.6.3)
celluloid (0.15.2)
chunky_png (1.3.1)
coderay (1.1.0)
color-schemer (0.2.8)
compass (0.12.6)
compass-blend-modes (0.0.2)
compass-normalize (1.5)
compass-rgbapng (0.2.1)
compass-validator (3.0.1)
css_parser (1.3.5)
dash (0.4.0)
fssm (0.2.10)
io-console (0.4.2)
json (1.8.1)
minitest (5.3.5, 4.7.5)
psych (2.0.5)
rake (10.3.2, 10.1.0)
rdoc (4.1.1, 4.1.0)
sass (3.2.19)
test-unit (2.5.5, 2.1.2.0)
timers (1.1.0)
But a new problem occur when I try running "drush omega-guard":
$ drush omega-guard
Which theme do you want to run Guard for?
[0] : Cancel
[1] : Ohm (Subtheme of Omega) - Omega based demonstration theme. Serves as a
best-practice reference for the Omega documentation. Ohm will be
constantly updated as best practice evolves so shouldn't be used in
production.
[2] : Omega - A powerful HTML5 base theme framework utilizing tools like
Sass, Compass, Grunt, Bower, Ruby Version Manager, Bundler and more.
[3] : Design (Subtheme of Omega) - Please provide a description for
your theme.
3
There was a problem with your setup: [error]
Resolving dependencies...
Bundler can't satisfy your Gemfile's dependencies.
Install missing gems with `bundle install`.
So I try using the command "bundle install" again but end up with an endless error message:
$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using addressable 2.3.6
Using chunky_png 1.3.1
Using fssm 0.2.10
Using sass 3.2.19
Using compass 0.12.6
Using breakpoint 2.0.7
Using timers 1.1.0
Using celluloid 0.15.2
Using coderay 1.1.0
Using compass-blend-modes 0.0.2
Using color-schemer 0.2.8
Using compass-normalize 1.5
Using compass-rgbapng 0.2.1
Using compass-validator 3.0.1
Using css_parser 1.3.5
0 [main] ruby 15100 child_info_fork::abort: address space needed by 'fcntl.so' (0x620000) is already occupied
0 [main] ruby 11364 child_info_fork::abort: address space needed by 'fcntl.so' (0x620000) is already occupied
1 [main] ruby 14584 child_info_fork::abort: address space needed by 'fcntl.so' (0x620000) is already occupied
The last three lines keep on repeating forever but with different numbers. So what is the problem this time?
Drush is a PHP app, not an Ruby one.
You need a PHP work environment (at first an PHP cli) to work with drush.

gem check errors (registered but missing gems) after installing ruby 2.0.0-p0 with rbenv install

Everything works fine with my installation of ruby 1.9.3.
$ rbenv global 1.9.3-p385
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.1.0)
io-console (0.3)
json (1.5.4)
minitest (2.5.1)
rake (0.9.2.2)
rdoc (3.9.5)
$ gem check
$
However after I installed ruby 2.0.0 with rbenv install, some strange error messages showed up in gem check.
$ rbenv install 2.0.0-p0
Downloading openssl-1.0.1e.tar.gz...
-> https://www.openssl.org/source/openssl-1.0.1e.tar.gz
Installing openssl-1.0.1e...
Installed openssl-1.0.1e to /Users/gogao/.rbenv/versions/2.0.0-p0
Downloading ruby-2.0.0-p0.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
Installing ruby-2.0.0-p0...
Installed ruby-2.0.0-p0 to /Users/gogao/.rbenv/versions/2.0.0-p0
$ rbenv global 2.0.0-p0
$ rbenv rehash
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.0)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
test-unit (2.0.0.0)
$ gem check
Checking gems...
bigdecimal-1.2.0.gem has 1 problems
bigdecimal-1.2.0:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bigdecimal-1.2.0
io-console-0.4.2.gem has 1 problems
io-console-0.4.2:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/io-console-0.4.2
json-1.7.7.gem has 1 problems
json-1.7.7:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/json-1.7.7
minitest-4.3.2.gem has 1 problems
minitest-4.3.2:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/minitest-4.3.2
psych-2.0.0.gem has 1 problems
psych-2.0.0:
Gem registered but doesn't exist at /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/psych-2.0.0
rake-0.9.6.gem has 2 problems
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rake-0.9.6.gem:
missing gem file /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rake-0.9.6.gem
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/specifications/rake-0.9.6.gemspec:
Spec file missing for installed gem
rdoc-4.0.0.gem has 2 problems
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rdoc-4.0.0.gem:
missing gem file /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/rdoc-4.0.0.gem
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/specifications/rdoc-4.0.0.gemspec:
Spec file missing for installed gem
test-unit-2.0.0.0.gem has 2 problems
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/test-unit-2.0.0.0.gem:
missing gem file /Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/cache/test-unit-2.0.0.0.gem
/Users/gogao/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/specifications/test-unit-2.0.0.0.gemspec:
Spec file missing for installed gem
$
Is it a known bug? or am i doing something wrong?
For Ruby 2.0.0-p0, I also get similar warnings from gem check. However, I don't have issues at runtime with any of these gems. I suspect this might be a bug with Rubygems check command in 2.0.0.
I have similar errors. Passing options to compiler fix installation.
Before install readline and openssl with Homebrew.
RUBY_CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)
--with-openssl-dir=$(brew --prefix openssl)" rbenv install 2.0.0-p0
More info from Original Post

could not find gem 'tenderlove-frex' when installing the gem melomel. where can i find this gem?

I am trying to install the gem melomel for testing in actionscript. When i require it in my gemfile and bundle update, i get an error saying that it cant find the gem tenderlove-frex and outputs this message:
Could not find gem 'tenderlove-frex (>= 0) ruby', which is required by gem 'spree (>= 0) ruby', in any of the sources.Bundler could not find compatible versions for gem "nokogiri":
In Gemfile:
spree (>= 0) ruby depends on
nokogiri (~> 1.5.0) ruby
spree (>= 0) ruby depends on
nokogiri (1.0.0)
When i remove melomel form my gemfile, bundle updates fine. I have looked all over online and it seems like every location where its been hosted has removed the gem.
Where can I get this gem? i am using ruby 1.9.3.
The frex gem is not hosted on the typical Gemcutter.
To get it, add GitHub to your gem sources:
gem sources -a http://gems.github.com
Then try installing the gem as usual:
gem install tenderlove-frex
In case it's helpful: tenderlove is the handle of Aaron Patterson, one of the top Ruby developers, and as far as I know he's replaced frex and likely has a better solution you can use. For example, can you update your Nokogiri gem to the current version, and also your Spree gem to the current version? This should remove the need for frex.
To see your versions:
$ gem list melomel
melomel (0.6.6)
$ gem list spree
spree (1.2.2)
spree_api (1.2.2)
spree_cmd (1.2.2)
spree_core (1.2.2)
spree_dash (1.2.2)
spree_promo (1.2.2)
spree_sample (1.2.2)
To update:
$ bundle update
To see dependency list for Nokogiri:
$ gem dependency nokogiri

Resources