louismullie / treat

Natural language processing framework for Ruby.
Other
1.37k stars 128 forks source link

Install as normal user #14

Closed profmaad closed 12 years ago

profmaad commented 12 years ago

Hi there,

I just tried installing treat on Arch linux and basically was completely unable to get it to work. As my normal user, I did gem install treat, which worked as expected. If I then do Treat.install inside IRB, I get the following error:


rirb(main):001:0> require 'treat'
=> true
irb(main):002:0> Treat.install

Treat Installer, v. 1.0.6

1. Install language-independent gem dependencies.

Do you want to :
1 - Install all default language-independent dependencies
2 - Select dependencies to install manually
3 - Skip this step 

Please enter one of 1, 2, 3: 
1

- Installing psych to (un)serialize annotated entities to YAML format.
Gem::FilePermissionError: You don't have write permissions into the /usr/lib/ruby/gems/1.9.1 directory.
    from /usr/lib/ruby/1.9.1/rubygems/installer.rb:448:in `verify_gem_home'
    from /usr/lib/ruby/1.9.1/rubygems/installer.rb:147:in `install'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
    from /usr/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/installer.rb:302:in `block in install_gem'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/kernel.rb:25:in `call'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/kernel.rb:25:in `silence_warnings'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/installer.rb:301:in `install_gem'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/installer.rb:141:in `block in install_dependencies'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/installer.rb:139:in `each'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/installer.rb:139:in `install_dependencies'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/installer.rb:62:in `install'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat.rb:56:in `install'
    from (irb):2
    from /usr/bin/irb:12:in `<main>'irb(main):003:0> 

The installer shouldn't try to install those files in /usr, after all the gem resides in ~/.gem.

If I do the same thing as root, the gem gets installed in /root/.gem, the install procedure works. But afterwords I am unable to use treat as a normal user, because it was installed into `/root/.gem'. Installing the gem as my user as well didn't work either, following error:

irb(main):001:0> require 'treat'
=> true
irb(main):002:0> "test sentence is failing".parse
RuntimeError: Could not find JAR file (looking in /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/bin/stanford/joda-time.jar).
    from /usr/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:39:in `load'
    from /usr/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:56:in `load_jar'
    from /usr/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:64:in `block in load_default_jars'
    from /usr/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:61:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:61:in `load_default_jars'
    from /usr/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:48:in `bind'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/loaders/stanford.rb:35:in `load'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/processors/parsers/stanford.rb:62:in `init'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/processors/parsers/stanford.rb:28:in `parse'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/entities/abilities/delegatable.rb:69:in `call_worker'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/entities/abilities/delegatable.rb:39:in `block (2 levels) in add_workers'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/proxies.rb:14:in `method_missing'
    from (irb):2
    from /usr/bin/irb:12:in `<main>'

So the installer installs system-wide, but the gem then looks locally for the files.

Please fix this, I am completely unable to use treat because of this. It seems to me that the installer should be installing where the gem is located.

louismullie commented 12 years ago

Thanks for this report.

Short answer:

  1. Normally, the Ruby gems installer should find the appropriate path to install the gems (i.e. the same as when using gem install). I don't really understand why it doesn't here, but unfortunately I can't really debug. Can you test it with Ruby loaded via RVM and see if it works that way?
  2. You don't really need the installer to use Treat. In your case, you should basically need to install stanford-core-nlp:
gem install stanford-core-nlp

And download either:

The JAR files should be placed under /bin/stanford/, and the model files under /models/stanford/ (inside the Treat gem folder).

You can also check out the manual install page from the wiki for more info.


Long answer: This "installer" thing has already given me a lot of trouble and seems like it wants to give me still more. The problem is that I just can't ask the user to install all of the ~50 gems that the library can potentially use, that would be complete overkill. This is a dilemma I have been facing from the start of this project and I'd be happy to know if there are any existing libraries that have found a nicer way to manage optional dependencies. Another possibility is to just let the user figure out which libraries to install on his/her own, by throwing helpful error messages, which is what I think I'll be moving toward in v. 2.0 (which I plan on releasing maybe in about a month). I'll just keep the installer as a download script to install the Stanford files.

profmaad commented 12 years ago

Thanks for the quick reply.

I did install the gem as proposed and installed all the english models locally in /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/. treat seems to find the JARs as well as the models, but complains about missing property files:

irb(main):001:0> require 'treat'
=> true
irb(main):002:0> "some text here".parse
RuntimeIOException: ERROR: cannot find properties file "{pos.model=/home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/models/stanford/taggers/english-left3words-distsim.tagger, parser.model=/home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/models/stanford/grammar/englishPCFG.ser.gz, annotators=tokenize, ssplit, pos, lemma, parse}" in the classpath!
    from /usr/lib/ruby/gems/1.9.1/gems/stanford-core-nlp-0.3.2/lib/stanford-core-nlp.rb:148:in `new'
    from /usr/lib/ruby/gems/1.9.1/gems/stanford-core-nlp-0.3.2/lib/stanford-core-nlp.rb:148:in `load'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/processors/parsers/stanford.rb:77:in `init'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/processors/parsers/stanford.rb:28:in `parse'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/entities/abilities/delegatable.rb:69:in `call_worker'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/entities/abilities/delegatable.rb:39:in `block (2 levels) in add_workers'
    from /home/profmaad/.gem/ruby/1.9.1/gems/treat-1.0.6/lib/treat/proxies.rb:14:in `method_missing'
    from (irb):2
    from /usr/bin/irb:12:in `<main>'

There is a .gem/ruby/1.9.1/gems/treat-1.0.6/models/stanford/taggers/english-left3words-distsim.tagger.props, though.

louismullie commented 12 years ago

First thing that comes to mind here is your Ruby version: are you running 1.9.1 or just storing your gems in there? Treat should not even let you run on 1.9.1 without throwing an exception, so I assume it is the latter (?) If you are running 1.9.1, you should probably update to 1.9.2 or 1.9.3 to run Treat, since they are the the two versions I develop and test on.

Otherwise, I just did a fresh install of treat-1.0.6 and stanford-core-nlp-0.3.2 and your example works as expected here (OS X, Ruby 1.9.2). I'll need your help debugging here... I'll try on my Ubuntu box later to see if this is a non-Mac issue.

profmaad commented 12 years ago

Ok, just tried on a clean install as well, and that works. So I guess its something about my failed Installer tries on my other machine. Guess this is closed then.

louismullie commented 12 years ago

Happy to know this worked out, and don't hesitate if you encounter any other unexpected stuff.