Skip to content

Commit

Permalink
Enable bundled gems in ruby-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 6, 2025
1 parent adbf9c5 commit 9baa0f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ruby-runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ insert_env_path(const char *envname, const char *paths, size_t size, int prepend
setenv(envname, env, 1);
}

#define insert_env_path_lit(env, path, prep) \
insert_env_path(env, path, sizeof(path), prep)

#define EXTOUT_DIR BUILDDIR"/"EXTOUT
int
main(int argc, char **argv)
Expand All @@ -81,6 +84,10 @@ main(int argc, char **argv)
insert_env_path(LIBPATHENV, builddir, dirsize, 1);
insert_env_path("RUBYLIB", rubylib, sizeof(rubylib), 0);

insert_env_path_lit("GEM_PATH", ABS_SRCDIR"/.bundle", 1);
insert_env_path_lit("GEM_PATH", BUILDDIR"/.bundle", 1);
if (!getenv("GEM_HOME")) setenv("GEM_HOME", ABS_SRCDIR"/.bundle", 1);

if (!(p = strrchr(arg0, '/'))) p = arg0; else p++;
if (strlen(p) < namesize - 1) {
argv[0] = malloc(p - arg0 + namesize);
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_overwrite_ENV
end;
end

MANDATORY_ENVS = %w[RUBYLIB RJIT_SEARCH_BUILD_DIR]
MANDATORY_ENVS = %w[RUBYLIB GEM_HOME GEM_PATH RJIT_SEARCH_BUILD_DIR]
case RbConfig::CONFIG['target_os']
when /linux/
MANDATORY_ENVS << 'LD_PRELOAD'
Expand Down

0 comments on commit 9baa0f8

Please sign in to comment.