Skip to content

Commit 6086f6f

Browse files
committed
wip Attempt to fix bundler install failures
1 parent 9699baf commit 6086f6f

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

examples/sandbox_07_ruby_sinatra.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ async def main() -> None:
4747
runtime = (
4848
os.getenv("SANDBOX_RUNTIME") or "node22"
4949
) # note: ruby runtime is not supported so we have to install ruby via dnf
50+
bundle_env = (
51+
"BUNDLE_APP_CONFIG=.bundle "
52+
"BUNDLE_USER_HOME=.bundle-home "
53+
"BUNDLE_PATH=vendor/bundle "
54+
"BUNDLE_CACHE_PATH=vendor/cache"
55+
)
5056

5157
# Sinatra default port is 4567
5258
port = 4567
@@ -101,8 +107,10 @@ async def main() -> None:
101107
"-lc",
102108
(
103109
f"cd {sandbox.sandbox.cwd} && "
104-
"bundle config set --local path vendor/bundle && "
105-
"bundle config set --local without 'development:test'"
110+
"mkdir -p .bundle-home vendor/cache && "
111+
f"{bundle_env} bundle config set --local path vendor/bundle && "
112+
f"{bundle_env} bundle config set --local cache_path vendor/cache && "
113+
f"{bundle_env} bundle config set --local without 'development:test'"
106114
),
107115
],
108116
)
@@ -118,7 +126,7 @@ async def main() -> None:
118126
"bash",
119127
[
120128
"-lc",
121-
(f"cd {sandbox.sandbox.cwd} && bundle install --jobs 4 --retry 3"),
129+
(f"cd {sandbox.sandbox.cwd} && {bundle_env} bundle install --jobs 4 --retry 3"),
122130
],
123131
)
124132
async for line in bundle_install_cmd.logs():
@@ -135,7 +143,8 @@ async def main() -> None:
135143
(
136144
f"cd {sandbox.sandbox.cwd} && "
137145
# Start via rackup using WEBrick, binding to 0.0.0.0 and selected port
138-
f"RACK_ENV=production bundle exec rackup -s webrick -o 0.0.0.0 -p {port}"
146+
f"RACK_ENV=production {bundle_env} "
147+
f"bundle exec rackup -s webrick -o 0.0.0.0 -p {port}"
139148
),
140149
],
141150
)

examples/sandbox_09_rails_api.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ async def main() -> None:
4141
runtime = (
4242
os.getenv("SANDBOX_RUNTIME") or "node22"
4343
) # note: ruby runtime is not supported so we install ruby via dnf
44+
bundle_env = (
45+
"BUNDLE_APP_CONFIG=.bundle "
46+
"BUNDLE_USER_HOME=.bundle-home "
47+
"BUNDLE_PATH=vendor/bundle "
48+
"BUNDLE_CACHE_PATH=vendor/cache"
49+
)
4450

4551
# Rails default port is 3000
4652
port = 3000
@@ -104,6 +110,7 @@ async def main() -> None:
104110
"--skip-action-cable "
105111
"--skip-system-test "
106112
"--skip-git "
113+
"--skip-bundle "
107114
"--force"
108115
),
109116
],
@@ -122,7 +129,12 @@ async def main() -> None:
122129
"bash",
123130
[
124131
"-lc",
125-
(f"cd {app_path} && bundle config set --local path vendor/bundle"),
132+
(
133+
f"cd {app_path} && "
134+
"mkdir -p .bundle-home vendor/cache && "
135+
f"{bundle_env} bundle config set --local path vendor/bundle && "
136+
f"{bundle_env} bundle config set --local cache_path vendor/cache"
137+
),
126138
],
127139
)
128140
async for line in bundler_cfg_cmd.logs():
@@ -137,7 +149,7 @@ async def main() -> None:
137149
"bash",
138150
[
139151
"-lc",
140-
(f"cd {app_path} && bundle install --jobs 4 --retry 3"),
152+
(f"cd {app_path} && {bundle_env} bundle install --jobs 4 --retry 3"),
141153
],
142154
)
143155
async for line in bundle_install_cmd.logs():
@@ -154,7 +166,7 @@ async def main() -> None:
154166
"-lc",
155167
(
156168
f"cd {app_path} && "
157-
"bundle exec rails generate scaffold Post title:string body:text"
169+
f"{bundle_env} bundle exec rails generate scaffold Post title:string body:text"
158170
),
159171
],
160172
)
@@ -183,7 +195,7 @@ async def main() -> None:
183195
"bash",
184196
[
185197
"-lc",
186-
(f"cd {app_path} && bundle exec rails db:migrate"),
198+
(f"cd {app_path} && {bundle_env} bundle exec rails db:migrate"),
187199
],
188200
)
189201
async for line in migrate_cmd.logs():
@@ -198,7 +210,7 @@ async def main() -> None:
198210
"bash",
199211
[
200212
"-lc",
201-
(f"cd {app_path} && bundle exec rails db:seed"),
213+
(f"cd {app_path} && {bundle_env} bundle exec rails db:seed"),
202214
],
203215
)
204216
async for line in seed_cmd.logs():
@@ -218,7 +230,8 @@ async def main() -> None:
218230
"-lc",
219231
(
220232
f"cd {app_path} && "
221-
f"ALLOWED_HOST={allowed_host} bundle exec rails server -b 0.0.0.0 -p {port}"
233+
f"ALLOWED_HOST={allowed_host} {bundle_env} "
234+
f"bundle exec rails server -b 0.0.0.0 -p {port}"
222235
),
223236
],
224237
)

0 commit comments

Comments
 (0)