Skip to content

Commit f245480

Browse files
author
Graham Jenson
authored
Merge pull request #40 from bazelruby/graham/rubocop-building
[Fix] rubocop builds
2 parents b1caead + 080d2ab commit f245480

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

examples/simple_script/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ ruby_test(
3030
"@bundle//:rspec",
3131
],
3232
)
33+
34+
# TODO: not the best way of defining this, should make `rubocop` rule like `buildifier`
35+
ruby_binary(
36+
name = "rubocop",
37+
srcs = [
38+
"@bundle//:bin/rubocop",
39+
],
40+
main = "@bundle//:bin/rubocop",
41+
deps = [
42+
"@bundle//:rubocop",
43+
],
44+
)

examples/simple_script/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ source 'https://rubygems.org'
44

55
gem 'awesome_print'
66
gem 'rspec', '~> 3.7.0'
7+
gem 'rubocop'

examples/simple_script/Gemfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4+
ast (2.4.0)
45
awesome_print (1.8.0)
56
diff-lcs (1.3)
7+
jaro_winkler (1.5.4)
8+
parallel (1.19.1)
9+
parser (2.6.5.0)
10+
ast (~> 2.4.0)
11+
rainbow (3.0.0)
612
rspec (3.7.0)
713
rspec-core (~> 3.7.0)
814
rspec-expectations (~> 3.7.0)
@@ -16,13 +22,23 @@ GEM
1622
diff-lcs (>= 1.2.0, < 2.0)
1723
rspec-support (~> 3.7.0)
1824
rspec-support (3.7.1)
25+
rubocop (0.77.0)
26+
jaro_winkler (~> 1.5.1)
27+
parallel (~> 1.10)
28+
parser (>= 2.6)
29+
rainbow (>= 2.2.2, < 4.0)
30+
ruby-progressbar (~> 1.7)
31+
unicode-display_width (>= 1.4.0, < 1.7)
32+
ruby-progressbar (1.10.1)
33+
unicode-display_width (1.6.0)
1934

2035
PLATFORMS
2136
ruby
2237

2338
DEPENDENCIES
2439
awesome_print
2540
rspec (~> 3.7.0)
41+
rubocop
2642

2743
BUNDLED WITH
2844
1.17.3

examples/simple_script/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ Update gemfile using
1010
```
1111
bundle lock --update
1212
```
13+
14+
### Rubocop
15+
Run rubocop with:
16+
17+
```
18+
bazel run :rubocop -- $(pwd)/* -a
19+
```

ruby/private/bundle/bundle.bzl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("//ruby/private:constants.bzl", "RULES_RUBY_WORKSPACE_NAME")
22

33
def install_bundler(ctx, interpreter, install_bundler, dest, version):
4-
args = ["env", "-i", interpreter, install_bundler, version, dest]
4+
args = [interpreter, install_bundler, version, dest]
55
environment = {"RUBYOPT": "--disable-gems"}
66

77
result = ctx.execute(args, environment = environment)
@@ -37,8 +37,6 @@ def bundle_install_impl(ctx):
3737

3838
# Install the Gems into the workspace
3939
args = [
40-
"env",
41-
"-i", # remove all environment variables
4240
ctx.path(ruby), # ruby
4341
"--disable-gems", # prevent the addition of gem installation directories to the default load path
4442
"-I", # Used to tell Ruby where to load the library scripts
@@ -58,8 +56,6 @@ def bundle_install_impl(ctx):
5856

5957
# Create the BUILD file to expose the gems to the WORKSPACE
6058
args = [
61-
"env",
62-
"-i", # remove all environment variables
6359
ctx.path(ruby), # ruby interpreter
6460
"--disable-gems", # prevent the addition of gem installation directories to the default load path
6561
"-I", # -I lib (adds this folder to $LOAD_PATH where ruby searchesf for things)

ruby/private/toolchains/repository_context.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
def _eval_ruby(ruby, script, options = None):
7-
arguments = ["env", "-i", ruby.interpreter_realpath]
7+
arguments = [ruby.interpreter_realpath]
88
if options:
99
arguments.extend(options)
1010
arguments.extend(["-e", script])

ruby/private/tools/repository_context.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
def _eval_ruby(ruby, script, options = None):
7-
arguments = ["env", "-i", ruby.interpreter_realpath]
7+
arguments = [ruby.interpreter_realpath]
88
if options:
99
arguments.extend(options)
1010
arguments.extend(["-e", script])

0 commit comments

Comments
 (0)