Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Umlaut app generator steps fail if dependencies not already installed #55

Open
ryanfb opened this issue Mar 8, 2016 · 1 comment
Open

Comments

@ryanfb
Copy link

ryanfb commented Mar 8, 2016

When I run e.g. umlaut my_new_app, during the generation process I see the lines:

       apply  /Users/ryan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/umlaut-4.1.7/lib/generators/umlaut_app_template.rb
      append    Gemfile
    generate    umlaut:remove_turbolinks
Could not find gem 'mysql2 (< 0.5, >= 0.3.13)' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
    generate    umlaut:install
Could not find gem 'mysql2 (< 0.5, >= 0.3.13)' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
         run  bundle install

At the end of this process, there's no ./config/umlaut_services.yml file in the app directory (presumably generate umlaut:install failed due to missing dependencies). If I run bundle exec rails generate umlaut:install again afterwards, the file gets generated because the Rails generator ran bundle install after https://github.com/team-umlaut/umlaut/blob/master/lib/generators/umlaut_app_template.rb.

There's probably a few different ways to go about fixing this:

  1. Add a command that runs bundle install to https://github.com/team-umlaut/umlaut/blob/master/lib/generators/umlaut_app_template.rb after appending to the Gemfile, but before calling generate. This may be a little redundant because apparently the default Rails generator will run bundle install afterwards anyway.
  2. Add mysql2 to the umlaut.gemspec dependencies, so that after a user runs gem install umlaut, they'll already have the mysql2 dependency when they run umlaut my_new_app (which passes -d mysql to the Rails generator).
  3. Move the generate calls in umlaut_app_template.rb into an after_bundle block. This is mentioned there as available in future versions of Rails, and looks like it was added in 4.2.x, so this would be a clean solution but break backward compatibility with other versions of Rails.
@jrochkind
Copy link
Member

Hmm, thanks for catching this, annoying. #3 sounds reasonable to me, if it works -- I think it's probably okay to require Rails 4.2 at this point, especially for future releases. We could also put some conditional logic in that does #3 if Rails.version is at least 4.2, but does it the old somewhat broken way in earlier Rails?

Interested in submitting a PR?

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

No branches or pull requests

2 participants