Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Easy name change #315

wants to merge 2 commits into from

4 participants


Help to easily make projects based on rebar (like rebar + lot of specific templates).
Just change the .app file and the macro APP with the name of the new application and bootstrap will generate your project.

  • ./bootstrap fails on R13 and R14.
  • The changes in rebar.config.sample exceed the column limit and have to be reformatted.
  • The ?APP definition in include/rebar.hrl should be either before the arity comment or after the logging macros.
  • The commit summaries should not end with a period (see Writing Commit Messages).
  • While at it, for building the .app path in bootstrap we might want to use filename:join.
  • While at it, Makefile should also be adapted (e.g. make clean).

On top of your changes, you need to rename ebin/ to rebar/ and make sure that the app definition in ebin/ uses NEW_NAME.

That said, I don't have a strong opinion on this, but is it crucial to have a different name than rebar for the binary, or would it work to just extend priv/templates before building rebar? Also, I suppose putting the templates in ~/.rebar/templates or in the local project doesn't solve your problem.


Thanks for your quick answer.
Extend priv/templates works well, but when you distribute a single file with a lot of specific stuff inside, it's essential that the user can differentiate it.


Why do you not use rebar as a dependency instead of doing this, which seems pretty convoluted.

@ferd ferd added the question label

I'm also wondering why this cannot be a dependency. I'm not super happy about the prospect of having multiple rebar-equivalents-just-with-different-names around. Is there a thing that keeps you from using it as a dependency?

I'll mark this as question for now, and if we don't have an answer within something like 2 weeks (because maybe vacations and whatnot during this summer), we'll be closing this.


Someone knows why R14 can't find include file "include/rebar.hrl" ?


Rebar is a fantastic tool and the erlang standard to dependancies.
As rebar is great for template generation, it should be the de facto standard tool for web frameworks.

BUT, the best erlang web developer drops rebar for some ugly Makefile:

Rebar is the great tool, I just want an easier way to do it..

Really ? DRY.

Don't be afraid of rebar being used ! With my proposition, as everybody will use rebar, all features wil be integrated upstream (i.e. rebar). Without it, real forks with different features will be create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
21 bootstrap
@@ -2,7 +2,10 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
main(Args) ->
+ App = atom_to_list(?APP),
%% Get a string repr of build time
Built = build_time(),
@@ -48,16 +51,16 @@ main(Args) ->
up_to_date ->
error ->
- io:format("Failed to compile rebar files!\n"),
+ io:format("Failed to compile " ++ App ++ " files!\n"),
%% Make sure file:consult can parse the .app file
- case file:consult("ebin/") of
+ case file:consult("ebin/" ++ App ++ ".app") of
{ok, _} ->
{error, Reason} ->
- io:format("Invalid syntax in ebin/ ~p\n", [Reason]),
+ io:format("Invalid syntax in ebin/ ~p\n", [App, Reason]),
@@ -73,10 +76,10 @@ main(Args) ->
%% or write out script files on win32.
case os:type() of
{unix,_} ->
- [] = os:cmd("chmod u+x rebar"),
+ [] = os:cmd("chmod u+x " ++ App),
{win32,_} ->
- write_windows_scripts(),
+ write_windows_scripts(App),
_ ->
@@ -84,10 +87,10 @@ main(Args) ->
%% Add a helpful message
io:format("Congratulations! You now have a self-contained script called"
- " \"rebar\" in\n"
+ " \"" ++ App ++ "\" in\n"
"your current working directory. "
"Place this script anywhere in your path\n"
- "and you can use rebar to build OTP-compliant apps.\n").
+ "and you can use " ++ App ++ " to build OTP-compliant apps.\n").
is_otp(OtpInfo, Regex) ->
case re:run(OtpInfo, Regex, [{capture, none}]) of
@@ -126,10 +129,10 @@ vcs_info([{Id, Dir, VsnCmd, StatusCmd} | Rest]) ->
-write_windows_scripts() ->
+write_windows_scripts(AppName) ->
"@echo off\r\n"
"set rebarscript=%~f0\r\n"
"escript.exe \"%rebarscript:.cmd=%\" %*\r\n",
- ok = file:write_file("rebar.cmd", CmdScript).
+ ok = file:write_file(AppName ++ ".cmd", CmdScript).
2  include/rebar.hrl
@@ -1,3 +1,5 @@
+-define(APP, rebar).
%% TODO: rename FAIL to ABORT once we require at least R13B04 for
%% building rebar. Macros with different arity were not supported by the
%% compiler before 13B04.
5 rebar.config.sample
@@ -77,6 +77,11 @@
{escript_comment, "%%\n"}.
{escript_emu_args, "%%! -pa application/application/ebin\n"}.
+%% If you change the name of the rebar application, still invoke the rebar
+%% module.
+ "%%! -pa application/application/ebin -escript main rebar\n"}.
%% == LFE Compiler ==
%% LFE files to compile before the rest
6 src/rebar.erl
@@ -69,7 +69,7 @@ main(Args) ->
%% Erlang-API entry point
run(BaseConfig, Commands) ->
- _ = application:load(rebar),
+ _ = application:load(?APP),
run_aux(BaseConfig, Commands).
%% ====================================================================
@@ -117,7 +117,7 @@ run(RawArgs) ->
load_rebar_app() ->
%% Pre-load the rebar app so that we get default configuration
- ok = application:load(rebar).
+ ok = application:load(?APP).
init_config({Options, _NonOptArgs}) ->
%% If $HOME/.rebar/config exists load and use as global config
@@ -313,7 +313,7 @@ set_log_level(Config, Options) ->
%% show version information and halt
version() ->
- {ok, Vsn} = application:get_key(rebar, vsn),
+ {ok, Vsn} = application:get_key(?APP, vsn),
?CONSOLE("rebar ~s ~s ~s ~s\n",
10 src/rebar_core.erl
@@ -36,8 +36,8 @@
help(ParentConfig, Commands) ->
%% get all core modules
- {ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
- {ok, RawCoreModules} = application:get_env(rebar, modules),
+ {ok, AnyDirModules} = application:get_env(?APP, any_dir_modules),
+ {ok, RawCoreModules} = application:get_env(?APP, modules),
AppDirModules = proplists:get_value(app_dir, RawCoreModules),
RelDirModules = proplists:get_value(rel_dir, RawCoreModules),
CoreModules = AnyDirModules ++ AppDirModules ++ RelDirModules,
@@ -136,7 +136,7 @@ process_dir(Dir, Command, ParentConfig, DirSet) ->
%% Get the list of processing modules and check each one
%% against CWD to see if it's a fit -- if it is, use that
%% set of modules to process this dir.
- {ok, AvailModuleSets} = application:get_env(rebar, modules),
+ {ok, AvailModuleSets} = application:get_env(?APP, modules),
ModuleSet = choose_module_set(AvailModuleSets, Dir),
skip_or_process_dir(Dir, Command, Config, DirSet, CurrentCodePath,
ModuleSet, WouldCd)
@@ -159,7 +159,7 @@ would_cd_into_dir1(Dir, Command, Config) ->
%% Check whether the command is part of the built-in (or extended via
%% rebar.config) list of default-recursive commands.
is_recursive_command(Command, Config) ->
- {ok, AppCmds} = application:get_env(rebar, recursive_cmds),
+ {ok, AppCmds} = application:get_env(?APP, recursive_cmds),
ConfCmds = rebar_config:get_local(Config, recursive_cmds, []),
RecursiveCmds = AppCmds ++ ConfCmds,
lists:member(Command, RecursiveCmds).
@@ -225,7 +225,7 @@ process_dir1(Dir, Command, Config, DirSet, CurrentCodePath,
%% of modules that are processed in addition to modules associated
%% with this directory type. These any_dir modules are processed
- {ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
+ {ok, AnyDirModules} = application:get_env(?APP, any_dir_modules),
Modules = AnyDirModules ++ DirModules,
Something went wrong with that request. Please try again.