Skip to content

Commit

Permalink
Do not fail rc file loading if we aren't in a workspace.
Browse files Browse the repository at this point in the history
Fixes #5906, removes the assert that the workspace exists, which I incorrectly added in the fix to #4502.

RELNOTES: None.
PiperOrigin-RevId: 209424088
  • Loading branch information
cvcal authored and Copybara-Service committed Aug 20, 2018
1 parent 7693b09 commit 44f92dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/cpp/option_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ blaze_exit_code::ExitCode OptionProcessor::GetRcFiles(
std::string* error) const {
assert(cmd_line != nullptr);
assert(result_rc_files != nullptr);
assert(!workspace.empty());

std::vector<std::string> rc_files;

Expand All @@ -272,8 +271,11 @@ blaze_exit_code::ExitCode OptionProcessor::GetRcFiles(
rc_files.push_back(system_rc);
}

// Get the workspace rc: %workspace%/.bazelrc (unless --noworkspace_rc)
if (SearchNullaryOption(cmd_line->startup_args, "workspace_rc", true)) {
// Get the workspace rc: %workspace%/.bazelrc (unless --noworkspace_rc), but
// only if we are in a workspace: invoking commands like "help" from outside
// a workspace should work.
if (!workspace.empty() &&
SearchNullaryOption(cmd_line->startup_args, "workspace_rc", true)) {
const std::string workspaceRcFile =
blaze_util::JoinPath(workspace, kRcBasename);
rc_files.push_back(workspaceRcFile);
Expand Down
3 changes: 2 additions & 1 deletion src/main/cpp/option_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class OptionProcessor {

// Finds and parses the appropriate RcFiles:
// - system rc (unless --nosystem_rc)
// - workspace, %workspace%/.bazelrc (unless --noworkspace_rc)
// - workspace, %workspace%/.bazelrc (unless --noworkspace_rc, or we aren't
// in a workspace directory, indicated by an empty workspace parameter)
// - user, $HOME/.bazelrc (unless --nohome_rc)
// - command-line provided, if a value is passed with --bazelrc.
virtual blaze_exit_code::ExitCode GetRcFiles(
Expand Down

0 comments on commit 44f92dd

Please sign in to comment.