Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Vanity generator not found #362

Open
jedeleh opened this issue Jul 25, 2019 · 1 comment
Open

Vanity generator not found #362

jedeleh opened this issue Jul 25, 2019 · 1 comment

Comments

@jedeleh
Copy link

jedeleh commented Jul 25, 2019

When I attempt to run the basic vanity generator, I get the following error:

Could not find generator 'vanity'. Maybe you meant 'vanity', 'task' or 'mailer'
Run `rails generate --help` for more options.

(of course, that error message brings up all kinds of existentialistic questions, Shroedinger's Cat and a nice vacation in Copenhagen)

I've tried a large number of variations of the command, including but not limited to:

rails generate vanity
rails generate Vanity:vanity
rails generate vanity:vanity
rails generate Vanity

Nothing seems to work. In reading the compatibility information in the README, I noticed that ruby 2.5.5 isn't mentioned as having been tested, and neither has Rails 5.2.3. I'm wondering if there's an issue in this or if my local setup is somehow compromised.

My next step was to clone vanity and run the specs. I got 12 failures, each ones being exactly like this one:

  1. NotificationType#compute_display_time when the rollup_schedule is valid natural language expression returns the next occurence on the schedule after the given date
    Failure/Error:
    expect(notification_type.compute_display_time(occurred_at)).to eq(
    Time.zone.parse("2019-04-26 09:15")
    )

    expected: 2019-04-26 09:15:00.000000000 -0500
    got: 2019-04-26 09:15:00.000000000 -0400

    (compared using ==)

    Diff:
    @@ -1,2 +1,2 @@
    -Fri, 26 Apr 2019 09:15:00 CDT -05:00
    +2019-04-26 09:15:00 -0400

    ./spec/models/notification_type_spec.rb:89:in `block (4 levels) in <top (required)>'

That set of failures might be on me--I'm using my laptop far from home this week and the output suggests a timezone issue.

Anyway, I guess it would be good to know if vanity is compatible with Ruby 2.5.5 & Rails 5.2.x. If it isn't, is that compatibility in the works?

Please note that I posted a related question on Stackoverflow: https://stackoverflow.com/questions/57185533/vanity-gem-strange-rails-generate-vanity-error

@jedeleh
Copy link
Author

jedeleh commented Jul 25, 2019

So digging into the generator itself via the console, I found that the VanityGenerator class was not loaded. I created an initializer in config/initializers/vanity.rb and puts require 'generators/vanity/migration_generator' inside. Generator works fine then. I imagine I'll have to do the same thing for the other generators. Perhaps this is a simple loadpath issue.

I didn't see this information in the README.md but saw that if you're using Rails this automagically is taken care of. This might not be true in ruby 2.4+ and Rails 4.2.11+.

I was able to reproduce this issue in a variety of our projects here using different ruby and rails versions with those noted above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant