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

Run rails new using specified prerelease version #39663

Merged
merged 3 commits into from Dec 15, 2021

Conversation

jonathanhefner
Copy link
Member

When running rails new with a prerelease flag like --edge, the project's Gemfile will point to the specified prerelease version, but the project itself is generated using the active version of Rails. This can cause problems if, for example, the prerelease version expects a different file structure than the active version. It also precludes using generator options that are new in the prerelease version.

This commit adds a mechanism to install and use prerelease versions of Rails when running rails new.

Closes #38761.


/cc @Schwad I added you as a co-author since you've been exploring this.

@rails-bot rails-bot bot added the railties label Jun 19, 2020
@jonathanhefner jonathanhefner force-pushed the rails-new-prerelease branch 4 times, most recently from 09b877c to 964adc1 Compare June 20, 2020 18:05
@jonathanhefner jonathanhefner added this to the 6.1.0 milestone Aug 14, 2020
railties/lib/rails/generators/app_base.rb Outdated Show resolved Hide resolved
bundle_command("install", "BUNDLE_GEMFILE" => gemfile)

require "shellwords"
bundle_command("exec rails #{self_command} #{Shellwords.join(@argv)}", "BUNDLE_GEMFILE" => gemfile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this commit in my machine and the fact that "BUNDLE_GEMFILE" is being set here is causing all the commands in the real generator to use this gemfile instead of the application's gemfile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I had tested this with --skip-webpack-install for performance reasons, and it worked, but I see now how it affects e.g. rails webpacker:install. I can fix that, but instead I'm going to try a slightly different approach that doesn't require setting BUNDLE_GEMFILE.

Application templates will still be affected by the bundle exec, but they can use an inline gemfile to require third-party gems, if they need them.

@rafaelfranca rafaelfranca removed this from the 6.1.0 milestone Aug 26, 2020
@rails-bot
Copy link

rails-bot bot commented Nov 30, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot bot added the stale label Nov 30, 2020
@rails-bot rails-bot bot removed the stale label Dec 5, 2020
@jonathanhefner jonathanhefner marked this pull request as draft December 9, 2020 01:28
@jonathanhefner jonathanhefner force-pushed the rails-new-prerelease branch 2 times, most recently from 834e3ba to c728b8e Compare December 12, 2020 17:14
Base automatically changed from master to main January 14, 2021 17:01
@rails-bot
Copy link

rails-bot bot commented Apr 14, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot bot added the stale label Apr 14, 2021
@Schwad
Copy link
Contributor

Schwad commented Apr 15, 2021

Hey @jonathanhefner - is this still a WIP or would you like for folks to try it out :)

@rails-bot rails-bot bot removed the stale label Apr 15, 2021
@jonathanhefner jonathanhefner force-pushed the rails-new-prerelease branch 2 times, most recently from 0eb681a to b743ac0 Compare April 18, 2021 18:10
@jonathanhefner jonathanhefner marked this pull request as ready for review April 18, 2021 18:22
@jonathanhefner
Copy link
Member Author

@Schwad Yes, please do test it out! 🙏 😃

@rails-bot
Copy link

rails-bot bot commented Jul 17, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

When running `rails new` with a prerelease flag like `--edge`, the
project's Gemfile will point to the specified prerelease version, but
the project itself is generated using the active version of Rails.  This
can cause problems if, for example, the prerelease version expects a
different file structure than the active version.  It also precludes
using generator options that are new in the prerelease version.

This commit adds a mechanism to install and use prerelease versions of
Rails when running `rails new`.

Closes rails#38761.

Co-authored-by: Nick Schwaderer <nicholas.schwaderer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants