Skip to content

Commit

Permalink
Fixed support for paths containing spaces
Browse files Browse the repository at this point in the history
Installing to any directory with spaces in the path failed because of GEM_HOME and GEM_PATH having not enough quotes around them and ruby failing to parse the options from RUBYOPT when the -r option had spaces in it.

Fixed this by adding the necessary escapes to add doublequotes around the env variables and moved restore_environment.rb to the lib/ruby/site_ruby/ folder, which is in the ruby load path, so the -r option doesn't need to reference the full absolute path.

Closes #38.

Contributed by Ville Immonen (@fson) in #94.
  • Loading branch information
FooBarWidget committed Feb 4, 2021
1 parent 7f95445 commit 5808f06
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* On Windows, dropped support for x86. Only x64 is now supported.
* The minimum supported macOS version is now 10.14 Mojave.
* The minimum supported Linux version is now RHEL 7 / CentOS 7 / Debian 8 / Ubuntu 14.06 / glibc 2.17.
* Fixed support for paths containing spaces. Contributed by Ville Immonen (@fson) in [PR #94](https://github.com/phusion/traveling-ruby/pull/94). Closes [issue #38](https://github.com/phusion/traveling-ruby/issues/38).
* Upgraded CA certificates from that of CentOS 5 to that of CentOS 8.
* Upgraded OpenSSL to 1.1.1i.
* Upgraded GMP to 6.2.1.
Expand Down
8 changes: 4 additions & 4 deletions linux/internal/build-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ echo ORIG_RUBYLIB=\"$RUBYLIB\"
echo LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:$ROOT/lib\"
echo SSL_CERT_FILE=\"$ROOT/lib/ca-bundle.crt\"
echo RUBYOPT=\"-r$ROOT/lib/restore_environment\"
echo RUBYOPT=\"-rtraveling_ruby_restore_environment\"
for DIR in "$ROOT"/lib/ruby/gems/*/deplibs/*/*; do
echo LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$DIR\"
done
EOF
echo "echo GEM_HOME=\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\"" >> "$FILE"
echo "echo GEM_PATH=\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\"" >> "$FILE"
echo "echo GEM_HOME=\\\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\\\"" >> "$FILE"
echo "echo GEM_PATH=\\\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\\\"" >> "$FILE"

cat >> "$FILE" <<EOF
echo RUBYLIB=\"$LOAD_PATHS\"
Expand Down Expand Up @@ -155,7 +155,7 @@ fi
run cp $USRLIBDIR/libtinfo.so.5 /tmp/ruby/lib/
run cp $USRLIBDIR/libreadline.so.6 /tmp/ruby/lib/
run cp /system_shared/ca-bundle.crt /tmp/ruby/lib/
run cp /system/restore_environment.rb /tmp/ruby/lib/
run cp /system/traveling_ruby_restore_environment.rb /tmp/ruby/lib/ruby/site_ruby/
export SSL_CERT_FILE=/tmp/ruby/lib/ca-bundle.crt

# Dump various information about the Ruby binaries.
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions osx/build-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ echo ORIG_RUBYLIB=\"$RUBYLIB\"
echo TERMINFO=/usr/share/terminfo
echo SSL_CERT_FILE=\"$ROOT/lib/ca-bundle.crt\"
echo RUBYOPT=\"-r$ROOT/lib/restore_environment\"
echo RUBYOPT=\"-rtraveling_ruby_restore_environment\"
EOF
echo "echo GEM_HOME=\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\"" >> "$FILE"
echo "echo GEM_PATH=\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\"" >> "$FILE"
echo "echo GEM_HOME=\\\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\\\"" >> "$FILE"
echo "echo GEM_PATH=\\\"\$ROOT/lib/ruby/gems/$RUBY_COMPAT_VERSION\\\"" >> "$FILE"

cat >> "$FILE" <<EOF
echo RUBYLIB=\"$LOAD_PATHS\"
Expand Down Expand Up @@ -292,7 +292,7 @@ pushd "$TMPBUILDROOT" >/dev/null

# Copy over various useful files.
run cp -pR "$RUNTIME_DIR"/lib/*.dylib* lib/
run cp "$SELFDIR/internal/restore_environment.rb" lib/
run cp "$SELFDIR/internal/traveling_ruby_restore_environment.rb" lib/ruby/site_ruby/
run cp "$SELFDIR/../shared/ca-bundle.crt" lib/
export SSL_CERT_FILE="$TMPBUILDROOT/lib/ca-bundle.crt"

Expand Down
File renamed without changes.

0 comments on commit 5808f06

Please sign in to comment.