<top (required)> undefined method "name" error #28

Closed
dkingofpa opened this Issue May 6, 2012 · 13 comments

Comments

Projects
None yet
5 participants

OS X 10.6.8
Ruby 1.9.2-p290
Ghost 0.3.0

dking@desktop21 ~/Projects $ gem install ghost
Fetching: ghost-0.3.0.gem (100%)
Successfully installed ghost-0.3.0
1 gem installed
Installing ri documentation for ghost-0.3.0...
Installing RDoc documentation for ghost-0.3.0...
dking@desktop21 ~/Projects $ ghost
USAGE: ghost add <hostname> [<ip=127.0.1.1>]
       ghost modify <hostname> <ip> OR <hostname> (will lookup ip)
       ghost delete <hostname>
       ghost delete_matching <pattern>
       ghost list [<filter>]
       ghost empty
       ghost export
       ghost import <file>
dking@desktop21 ~/Projects $ ghost list
Listing 0 host(s):
dking@desktop21 ~/Projects $ ghost add local.test
/Users/dking/.rvm/gems/ruby-1.9.2-p290/gems/ghost-0.3.0/bin/ghost:33:in `<top (required)>': undefined method `name' for nil:NilClass (NoMethodError)
    from /Users/dking/.rvm/gems/ruby-1.9.2-p290/bin/ghost:19:in `load'
    from /Users/dking/.rvm/gems/ruby-1.9.2-p290/bin/ghost:19:in `<main>'

Ghost 0.2.8 appears to be working (but I've only tried one command so far).

dking@desktop21 ~/Projects $ gem uninstall ghost -v 0.3.0
Remove executables:
    ghost-ssh

in addition to the gem? [Yn]  y
Removing ghost-ssh
Successfully uninstalled ghost-0.3.0
dking@desktop21 ~/Projects $ gem install ghost -v 0.2.8
Successfully installed ghost-0.2.8
1 gem installed
Installing ri documentation for ghost-0.2.8...
Installing RDoc documentation for ghost-0.2.8...
dking@desktop21 ~/Projects $ ghost
USAGE: ghost add <hostname> [<ip=127.0.1.1>]
       ghost modify <hostname> <ip> OR <hostname> (will lookup ip)
       ghost delete <hostname>
       ghost delete_matching <pattern>
       ghost list
       ghost empty
       ghost export
       ghost import <file>
dking@desktop21 ~/Projects $ ghost list
Listing 0 host(s):
dking@desktop21 ~/Projects $ ghost add local.test
Password:
  [Adding] local.test -> 127.0.0.1
dking@desktop21 ~/Projects $ ghost list
Listing 1 host(s):
  local.test -> 127.0.0.1

@bjeanes - Any thoughts on the issue?

I can confirm I'm seeing the same issue in ruby 1.9.3-p0

ghost add superdeluxetwo.local
/Users/samsutton/.rvm/gems/ruby-1.9.3-p0@global/gems/ghost-0.3.0/bin/ghost:33:in `<top (required)>': undefined     method `name' for nil:NilClass (NoMethodError)
    from /Users/samsutton/.rvm/gems/ruby-1.9.3-p0@global/bin/ghost:19:in `load'
    from /Users/samsutton/.rvm/gems/ruby-1.9.3-p0@global/bin/ghost:19:in `<main>'

As stated above, 0.2.8 seems to be fine.

Owner

bjeanes commented May 20, 2012

Ah sorry guys... I joined a noisy GH organization and changed my notification settings. I'm looking into this now. Note: this branch gets very little love... the "new" ghost is in the next branch and is close to needing some testers. I hope to release a pre-release version soon.

Owner

bjeanes commented May 20, 2012

@dkingofpa I can't replicate this. :(

Adding works fine for me on 1.9.2 and 1.9.2. Is there any other information you can provide me with?

@bjeanes Perhaps it's a version issue with other gems? Here's a list of my installed gems. And I'm using rvm.

Owner

bjeanes commented May 20, 2012

@dkingofpa can you create a fresh rvm gemset with minimal other gems to confirm that? I doubt other gems would interfere since this has no dependencies.

Rather than troubleshoot a version that will be obsolete soon (hopefully?), I'll just wait for for the "next" branch to be released.

turadg added a commit to turadg/ghost that referenced this issue Aug 28, 2012

Pass dscl create errors up to the ghost user
Currently when the `create` command fails, the `add()` function simply returns nil and the user never sees the error. They just get a confusing `undefined method "name" error` exception as in issue #28.

This patch raises an error with the `dscl` output as its message.
Contributor

turadg commented Aug 28, 2012

@dkingofpa your Ghost:Host.add() is returning nil, probably because the dscl command failed. Try running with sudo.

To give better error output in the future, I propose the patch in #32.

Owner

bjeanes commented Sep 5, 2012

Can you please try version 1.0.0.pre?

I am only using /etc/hosts now (though I have dscl support written just not activated) because the dscl interactions are far too unpredictable with different OS X versions. I plan to allow users to be explicit about requesting dscl as the backend, but defaulting to /etc/hosts in all cases.

Contributor

turadg commented Sep 5, 2012

Works perfectly. OSX 10.8.1

fwiw, ghost delete_matching appears broken.

Stone:~ turadg$ sudo ghost delete_matching mydev
No such task
Owner

bjeanes commented Sep 5, 2012

Nice ... good to hear.

Actually, delete_matching got folded into delete:

$ ghost help delete
Usage: ghost delete <host name|regex>

Remove a ghost-managed host.

The delete task accepts either a literal host name, or a regular
expression, notated with surrounding forward slashes (/). If a
host name is provided, it will delete only the entries whose host
names are equal to the provided host name. If a regular expression
is provided, all entries whose host names match the regular
expression will be deleted.

Depending on your shell, you may need to escape or quote the
regular expression to ensure that the shell doesn't perform
expansion on the expression.

Examples:
  ghost delete foo.com       # will delete foo.com
  ghost delete /^fo+\.com$/  # will delete fo.com, fooooo.com, etc.

I'll be sure to update the docs before a final release.

Confirmed that running via sudo fixes for me on OSX ( was having this issue without sudo )

@bjeanes bjeanes closed this Feb 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment