Skip to content

A before_rails_new/before_everything stage? #158

@travisp

Description

@travisp

I've been playing with rails_apps_composer, but one thing seemed different from my existing workflow. I tend to keep my global rvm gemset very bare (including without rails) and usually have the following process for a new application:

  1. create application specific gemset
  2. switch to application specific gemset
  3. add .rvmrc file with application specific gemset
  4. install the rails gem
  5. proceed...

But, the rvmrc recipe in rails_apps_composer occurs after "rails new" is run, requiring rails to be installed already (and into the global gemset). Maybe my approach is more unusual, but I wonder if there might not be some general use for a before_everything stage where some very initial setup could occur?

Activity

AJ-Acevedo

AJ-Acevedo commented on Feb 6, 2013

@AJ-Acevedo
Contributor

Where do you save the .rvmrc file before your rails app is created? Adding rails to the app gemset would also add a substantial amount of time to the initial setup time.

DanielKehoe

DanielKehoe commented on Feb 6, 2013

@DanielKehoe
Member

Yes, @travisp, please clarify.

My workflow is:

  1. create application specific gemset
  2. switch to application specific gemset
  3. 'gem install rails'
  4. 'rails new myapp' or 'rails new myapp -m some_template' or 'rails_apps_composer new myapp'
  5. 'cd myapp'
  6. 'rvm ruby-1.9.3@myapp --rvmrc'
  7. add gems to Gemfile
  8. 'bundle install'

How do you manage the .rvmrc file before the app is created?

travisp

travisp commented on Feb 7, 2013

@travisp
Author

To clarify my steps: the .rvmrc file is created in the new target application directory, and rails new is simply run with "rails new ." -- I guess I was leaving out that I create the application directory first too. In rails_apps_composer's case, the new application directory could be created, .rvmrc stuck into it, and then run rails new and install into the same new directory (it won't touch the existing rvmrc).

However, when the rvmrc file is created (my step 3) is less important because it could also be created later in my workflow. The main point of what I wanted to do was to enable rails_apps_composer to perform steps 1-3 of @DanielKehoe's workflow, since these are part of the steps every time anyway. The current rvmrc recipe performs steps 1-2 at the end, which doesn't make nearly as much sense to me (and presumably still also needs to install rails into the newly created gemset).

Adding rails to the app gemset does take time (less if you use "--no-ri --no-rdoc"), but it has to be done anyways with my or @DanielKehoe's workflow. So, it wouldn't actually take any additional time unless you're constantly rerunning rails_apps_composer

If this isn't generally wanted in the project I'll probably just create my own wrapper script to replace the use of the rvmrc recipe and perform the initial steps of the workflow before calling rails_apps_composer.

DanielKehoe

DanielKehoe commented on Feb 7, 2013

@DanielKehoe
Member

@travisp this is very interesting. First time I've seen the suggestion to make a directory and then run 'rails new .' Clever. I'm intrigued by the possibility of reworking r_a_c in this direction. A few reservations, though. Not everyone wants to use rvm, some use rbenv. And I'm told rvm and rbenv may become superfluous with the release of Rails 4. I don't want to rework r_a_c to become dependent on rvm. I'll investigate further as I have time.

DanielKehoe

DanielKehoe commented on Feb 7, 2013

@DanielKehoe
Member

So @travisp taught me something new today, thanks!

Here's my new workflow for creating a Rails app using rvm (simple case):

$ mkdir myapp
$ cd myapp
$ rvm use ruby-1.9.3@myapp --rvmrc --create
$ gem install rails
$ rails new .

Here's the new workflow using the current version of r_a_c with rvm:

$ mkdir myapp
$ cd myapp
$ rvm use ruby-1.9.3@myapp --rvmrc --create
$ gem install rails_apps_composer
$ gem install rails
$ rails_apps_composer new . -r core

In this case, it makes no difference if you answer 'yes' when r_a_c asks if you want to create a project-specific gemset and .rvmrc (you already have both so it continues without error).

Here's a proposed workflow using a hypothetical future version of r_a_c:

# install rails_apps_composer into the global gemset
$ gem install rails_apps_composer
$ mkdir myapp
$ cd myapp
$ rails_apps_composer new . -r core --rvm
# rails_apps_composer could run 'rvm use ruby-1.9.3@myapp --rvmrc --create'
# rails_apps_composer could run 'gem install rails'
# then rails_apps_composer could execute 'rails new . -m <tempfile>'

We'd give r_a_c a new flag --rvm to direct it to create a project-specific gemset and .rvmrc before running the application template. Alternatively, we could detect if rvm is running (so we wouldn't need the flag).

I'm not convinced of the value of the proposed approach. It saves two manual steps but it requires installing the rails_apps_composer gem in the global gemset.

One side benefit might be eliminating the problems caused by people running r_a_c with stale gems (issue #148). But it only helps if rvm is installed.

Further thoughts?

travisp

travisp commented on Feb 7, 2013

@travisp
Author

It does have some value to me (although admittedly nothing I can't manage manually or with a wrapper script) and I suppose having to install r_a_c in the global (or other individual) gemset has its own set of advantages/disadvantages.

I'm unfamiliar with the proposed changes to Rails 4 that might make rvm superfluous. If that's actually the case, I would agree that it's not worth the effort.

Maybe it would be best to wait and see if others would also find this valuable if it's not a trivial amount of changes.

AJ-Acevedo

AJ-Acevedo commented on Feb 7, 2013

@AJ-Acevedo
Contributor

@DanielKehoe Do you have a link to the proposed changes to Rails 4 that might make rvm superfluous?

DanielKehoe

DanielKehoe commented on Feb 7, 2013

@DanielKehoe
Member

@AJ-Acevedo My comment about "changes in Rails 4 that might make rvm superfluous" is conjecture based on comments from someone working on Bundler. So nothing substantial.

DanielKehoe

DanielKehoe commented on Feb 20, 2013

@DanielKehoe
Member

I've released a new version of rails_apps_composer and the Rails Composer application template that detects if the .rvmrc file already exists and only asks if you want to create a gemset and .rvmrc file if the .rvmrc file doesn't exist.

This doesn't implement @travisp's request but it prevents the display of the "create .rvmrc?" question in his workflow.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @travisp@DanielKehoe@AJ-Acevedo

        Issue actions

          A before_rails_new/before_everything stage? · Issue #158 · RailsApps/rails_apps_composer