-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ./bin for your app's executables: bin/bundle, bin/rails, bi…
…n/rake. Executable scripts are versioned code like the rest of your app. To generate a stub for a bundled gem: 'bundle binstubs unicorn' and 'git add bin/unicorn'
- Loading branch information
Showing
31 changed files
with
163 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'pathname' | ||
|
||
module Rails | ||
module AppRailsLoader | ||
RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"] | ||
EXECUTABLE = 'bin/rails' | ||
|
||
def self.exec_app_rails | ||
cwd = Dir.pwd | ||
return unless in_rails_application_or_engine? || in_rails_application_or_engine_subdirectory? | ||
exec RUBY, EXECUTABLE, *ARGV if in_rails_application_or_engine? | ||
Dir.chdir("..") do | ||
# Recurse in a chdir block: if the search fails we want to be sure | ||
# the application is generated in the original working directory. | ||
exec_app_rails unless cwd == Dir.pwd | ||
end | ||
rescue SystemCallError | ||
# could not chdir, no problem just return | ||
end | ||
|
||
def self.in_rails_application_or_engine? | ||
File.exists?(EXECUTABLE) && File.read(EXECUTABLE) =~ /(APP|ENGINE)_PATH/ | ||
end | ||
|
||
def self.in_rails_application_or_engine_subdirectory?(path = Pathname.new(Dir.pwd)) | ||
File.exists?(File.join(path, EXECUTABLE)) || !path.root? && in_rails_application_or_engine_subdirectory?(path.parent) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
require 'rubygems' | ||
load Gem.bin_path('bundler', 'bundle') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
APP_PATH = File.expand_path('../../config/application', __FILE__) | ||
require_relative '../config/boot' | ||
require 'rails/commands' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require_relative '../config/boot' | ||
require 'rake' | ||
Rake.application.run |
5 changes: 0 additions & 5 deletions
5
railties/lib/rails/generators/rails/app/templates/script/rails
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoaa..... 👿
009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this supposed to work with bundler's --binstubs turned on? The contents of bin/rails as a result of bundler vs. rails:update:bin are not the same, and the former won't start rails server properly. Heroku is also not able to start the rails server since this change, even pushing the bin folder up to it.
009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrismo It isn't. Bundler 1.3.0 will no longer overwrite executables in
./bin
. We'll prefer to usebundler binstubs <gem>
to explicitly add stubbed executables.009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - didn't know that, thx.
though browsing their commits just now, saw this one from 2 days ago -> rubygems/bundler@6540131 seems to undo that back to current (pre 1.3.0) behavior?
009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this appears to have been fixed -> rubygems/bundler#2253 -> rubygems/bundler@08138dc ... and with 1.3.0.pre7 it's no longer overwriting my local bin/rails.
009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and undone again in pre8 and now 1.3.0. rubygems/bundler@f00e085
https://gist.github.com/chrismo/5043420
I still may just be doing something wrong, but otherwise it seems there's some disagreement here on the tooling. Maybe --binstubs is just not a common use case?
EDIT: sorry - should have searched the issues more thoroughly -> "Use the new bundle binstubs command."
009873a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a very common use case. We'd like to see that change. Try not using
--binstubs
anymore and start checking your./bin/*
in to version control.