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

Already on GitHub? Sign in to your account

`rails new` (Rails 3.2.8) fails to generate a working application #7596

Closed
jarl-dk opened this Issue Sep 11, 2012 · 49 comments

Comments

Projects
None yet
10 participants

jarl-dk commented Sep 11, 2012

When generating a vanilla rails application (disabling javascript, sprockets, test-unit and active-record), rails new fails to generate a working application:

  1. running rails new vanilla_app --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit --edge --skip-bundle generates the project in https://github.com/jarl-dk/vanilla_app/tree/ea6e30a072d61cc1a01d04b77469010d229d57af

cding into vanilla_app, then bundle install pukes with

Bundler could not find compatible versions for gem "journey":
  In Gemfile:
    rails (>= 0) ruby depends on
      journey (~> 1.0.4) ruby

    journey (2.0.0.20120723141804)
  1. After fixing that I have this project https://github.com/jarl-dk/vanilla_app/tree/0a68a4452ebf4d647925182facdf4a9f1007969e

When running bundle exec ./script/rails server and visit http://localhost:3000/ The console pukes with

ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):
Owner

rafaelfranca commented Sep 11, 2012

  1. Was fixed @ 0ec7b35

  2. Occurs because you don't have the /assets/rails.png inside your public directory neither sprockets.

jarl-dk commented Sep 11, 2012

Thanks for letting me know about 0ec7b35. It seems part of 3-2-stable, so it will probably work at 3.2.9.

Regarding (2): You are right. You have explained the problem. But the problem still exists! I have explicitly requested rails to generate an application without sprockets using --skip-sprockets. If applications generated with this option is not expected to work (is unsupported), I suggest this option is removed.

This bug should be opened again.

Owner

rafaelfranca commented Sep 11, 2012

@jarl-dk I'm note sure that (2) should be fixed but I'll reopen to get more feedback.

Thanks

@carlosantoniodasilva @guilleiguaran @josevalim

@rafaelfranca rafaelfranca reopened this Sep 11, 2012

Member

steveklabnik commented Sep 11, 2012

If an app can be generated in an unusable state, that's a bug, imho.

Contributor

revans commented Sep 11, 2012

I cannot reproduce the rails.png missing image with this command (after fixing journey)

rails new vanilla_app --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit --edge --skip-bundle

Or by cloning your repo @jarl-dk: https://github.com/jarl-dk/vanilla_app.git

jarl-dk commented Sep 11, 2012

@revans : Have you tried bundle exec ./script/rails server and visit http://localhost:3000/ ?

Contributor

revans commented Sep 11, 2012

@jarl-dk Yea, I did try with

bundle exec ./script/rails server
and the server starts up fine and serves the index.html page as expected.

jarl-dk commented Sep 11, 2012

There are no errors in the browser. It pukes in the terminal. To me it is 100% reproducible both with
ruby-1.9.2-p320 and ruby-1.9.3-p194

@rafaelfranca : Could you try?

jarl-dk commented Sep 11, 2012

@revans : Does it also show the rails.png image?

Contributor

revans commented Sep 11, 2012

Sorry @jarl-dk you're right, I can confirm this as a bug.

jarl-dk commented Sep 11, 2012

@revans : No worries. I am glad you can see the problem as well... So far so good. :-)

Contributor

revans commented Sep 12, 2012

@rafaelfranca Did you get any feedback on this?

I looked into this briefly and when skipping sprockets the rails.png is still put in app/assets/images instead of something like public/assets (which would work if the image was there).

I agree with @steveklabnik and @jarl-dk that this is a bug and I can write a patch for it - just want to make sure since it seems this might be something that shouldn't be fixed.

Owner

rafaelfranca commented Sep 12, 2012

@revans if you want to fix, please do it.

My concerns is that I always remove this file and the index.html using a Rails template, so I don't care about they, since they are only for new users.

I this file change the place depending the options that I pass it will make harder to create this kind of templates.

If you are disabling javascript and sprockets I'm assuming that you is not a new user. And since it is not raising a 500 and impending you to work I'm still thinking if we will have some advantage with this fix.

jarl-dk commented Sep 12, 2012

Well, I can tell you that rails.png is not the only problem...
If you do something like

bundle exec ./script/rails generate scaffold post title body:text published:boolean

It will spit out code that also expects sprockets to be enabled. It will (when visiting /posts/new) complain about css files and javascript files. So the problem is slightly large than just a single PNG file at the wrong place.

Contributor

revans commented Sep 12, 2012

Yea. --skip-sprockets seems to only be partially implemented. All assets are still put in the app/assets directory instead of the public/assets directory where rails is looking for them.

Contributor

sheerun commented Sep 29, 2012

I have the same error (Bundler could not find compatible versions for gem "journey"), no matter what parameters I use for rails new rails4 --edge. Is it for sure fixed for current edge rails?

Contributor

Deradon commented Sep 30, 2012

Also getting the Bundler could not find compatible versions for gem "journey" when creating a new edge-rails project.
(rails new edgy_project --edge)

rvm info
=>


  system:
    bash:        "/bin/bash => GNU bash, Version 4.2.8(1)-release (i686-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]"
    updated:      "8 months 5 days 7 hours 16 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p0"
    date:         "2011-10-30"
    platform:     "i686-linux"
    patchlevel:   "2011-10-30 revision 33570"
    full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]"`

jarl-dk commented Sep 30, 2012

@sheerun I suggest you open another bug, since your experience is on edge... This bug is on 3.2.x branch

Further, @sheerun, @Deradon It seems like you are just discovering what @rafaelfranca explain is fixed in 0ec7b35 (for 3-2-stable). Your issues is mot likely that this commit is not (yet) merged into master (edge)

Contributor

revans commented Oct 1, 2012

I finally got some time to work on this. @rafaelfranca do you want a patch for the 3.2.x branch or should we do this in master?

Member

steveklabnik commented Oct 1, 2012

Patches go to master first and then get backported if it's relevant.

Contributor

revans commented Oct 1, 2012

Ok, cool. Thanks!

Contributor

revans commented Oct 1, 2012

For Javascript/Stylesheets, should the generator skip creating these files (e.g. rails g scaffold posts) or create them in the public/assets folder? (when skip-sprockets is used)

My gut says to skip creating them.

Owner

rafaelfranca commented Oct 2, 2012

I'm still not sure if we should fix this case. But if we are fixing I prefer to skip creating them too.

Owner

rafaelfranca commented Oct 2, 2012

@sheerun @Deradon you guys is still getting this failure because you are using the 3.2.8 rails "binary" and that fix was not released in 3.2.8

Also currently there is no way to generate a Rails 4 application without cloning the repository. I explained it with more details here #7773 (comment)

Contributor

Deradon commented Oct 2, 2012

@rafaelfranca Thanks for this info.
Generating a Rails 4 App after cloning the repo works fine!

jarl-dk commented Oct 2, 2012

Jus to make sure: Point (2) in this bug report is also a problem on master.

Generating a vanilla Rails 4 app (using master commit 0d41d69) works fine but the application that is generated is broken:
Generating with

PATH_OF_YOUR_RAILS_FORK/railties/bin/rails new vanilla_app --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit --edge

then cd vanilla_app/
When running ./script/rails server and visit http://localhost:3000/, then the console pukes with

ActionController::RoutingError (No route matches [GET] "/assets/rails.png")
Owner

guilleiguaran commented Oct 2, 2012

Should we really care about fixing it? The fix should be easy but I'm not sure if it's worth fixing.

I would not worry about it, the app is usable, you can see the info in the index.html and later you will finish removing the index.html anyway...

jarl-dk commented Oct 2, 2012

I share the opinion of @steveklabnik: If it is not fixed I think we should remove the possibility to --skip-sprockets or whatever is the offending option. See also my comment #7596 (comment) ; The rails.png is not the only problem.

Contributor

revans commented Oct 2, 2012

@jarl-dk I have the first case of the missing rails.png already fixed in my branch. I'm just working on the scaffold/controller/asset generators and making sure they don't generate an asset when you have used --skip-sprockets to create the application.

@rafaelfranca I think we should fix it or remove the --skip-sprockets option. Rails generators generate and the server looks for assets in the app/assets directory regardless if you use the --skip-sprockets. So it's not just rails.png image but any asset actually which get created by scaffold/controller/asset generators. (assets get created regardless of --skip-sprockets option)

In the config/application.rb the config.assets.enabled = true is removed when the --skip-sprockets is used, but the config.assets.enabled is to set to true as the default in the rails source. It needs to be set to false when using that option.

I've got most of this fixed already, just wanted feedback on what to do when generators are ran - create the asset in public/assets or skip it all together. I think skipping it is what would be expected by the end user.

Owner

guilleiguaran commented Oct 2, 2012

@revans ping me when the PR is open, about the config.assets.enabled I will convert in a no-op

Contributor

revans commented Oct 2, 2012

@guilleiguaran I was going to use that [config.assets.enabled] as the config for generating assets or not. If set to false, no assets are generated. If set to true, then the assets are generated. Do you (or anyone) see any issues with that?

jarl-dk commented Oct 2, 2012

I don't quite get the end of this story:
Is this fixed?
Is the --skip-sprockets option removed
Is this accepted as not working?

The answers are probably 'no', 'no', and 'yes' for Rails 3.2.x, but what about edge?
It sounds like @revans has almost fixed it on edge. Is that true?

Contributor

revans commented Oct 2, 2012

@jarl-dk I'm working on the patch - trying to get some time away from work to finish this. When I finish, it'll be fixed on edge (master).

jarl-dk commented Oct 3, 2012

@revans : I now see that I misunderstood the comment #7596 (reference) because of the red "Closed" label to the right; I thought it applied to this issue, but it was #7773 that was closed. That is what confused me. Sorry, I did not mean to stress you.

Contributor

revans commented Oct 3, 2012

@jarl-dk You didn't stress me. I feel bad that this has sat so long since I first started digging into it. :)

Owner

rafaelfranca commented Oct 6, 2012

@revans I don't see any problem in accepting a pull request that fixes this.

I don't think we should remove the --skip-sprockets option since it is very useful but I agree that we should not generate assets inside the app/assets folder. I'm fine with skiping these files in the generator.

Owner

guilleiguaran commented Oct 6, 2012

@revans actually I think the assets generators should be extracted to sprockets-rails and the sprockets-rails railtie shouldn't be loaded when --skip-sprockets is passed

Owner

rafaelfranca commented Oct 6, 2012

I agree with @guilleiguaran.

@guilleiguaran @rafaelfranca can we already consider this done?

jarl-dk commented Nov 11, 2012

@carlosantoniodasilva : Why should we consider this done?

@jarl-dk sorry, I meant the last @guilleiguaran comment about extracting the generators :)

Owner

guilleiguaran commented Nov 11, 2012

@carlosantoniodasilva no one have sent a PR for it yet, I think I will add it to my list.

@guilleiguaran alright, just wondering if this was something to be done, thanks :)

Contributor

gaurish commented Dec 11, 2012

assets generators should be extracted to sprockets-rails and the sprockets-rails railtie shouldn't be loaded when --skip-sprockets is passed

this is the decided solution? if so, is anyone working to implement this? If nobody is working, then I can try to write a patch over the weekend & open a PR.

Contributor

revans commented Dec 11, 2012

@gaurish I was initially working on it, but right now I am swamped with work. Feel free to submit a PR.

Contributor

gaurish commented Dec 12, 2012

Okay, I looked into this & I don't think we should exact asset generators into sprockets-rails. here is why:

we mokey-patch & make asset generators available whenever sprockets-rails is included as gem. asset generation would be skipped incase sprockets-rails is not included(--skip-sprockets).
so I guess this change would split generators into places, asset generators in sprockets-rails & rest still in railties. won't that confusing that generators are now at two places. IMHO, this is too much change for little gain. so I agree with @rafaelfranca

If you are disabling javascript and sprockets I'm assuming that you is not a new user. And since it is not raising a 500 and impending you to work I'm still thinking if we will have some advantage with this fix.

what if we simply spit out a warning message at the end of application generation log saying

  • Warning: --skip-sprockets option was used, asset-pipeline is disabled. you might see lot of ActionController::RoutingError in your logs & all assets(css/js/images) located in app/assets would return 404 errors . to fix this, move all the assets from app/assets to public.

I think this is a good solution.

Contributor

nertzy commented Mar 16, 2013

This is still an issue. I just tried with the latest edge Rails. I like the warning idea.

Contributor

gaurish commented May 8, 2013

This error is no longer reproducible on rails/rails@master. no more RoutingError in logs. so I guess this issed can be closed?

jarl-dk commented May 9, 2013

Its also fixed in the latest 3.2.x

@jarl-dk jarl-dk closed this May 9, 2013

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